summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormikeb <mikeb@openbsd.org>2016-09-12 18:55:18 +0000
committermikeb <mikeb@openbsd.org>2016-09-12 18:55:18 +0000
commitfdb94596f93fb7c46dc1e934565b553b64fa6167 (patch)
tree4ed2e0b9e5c3677675d290ab2e5994d22a7bb1a0
parentIf we can't get the CWD, use relative paths. Fixes editing files (diff)
downloadwireguard-openbsd-fdb94596f93fb7c46dc1e934565b553b64fa6167.tar.xz
wireguard-openbsd-fdb94596f93fb7c46dc1e934565b553b64fa6167.zip
Correctly account for fragments larger than a page size
Fix a subtle calculation bug that prevented larger fragments from being properly broken down into pages and overflowing the counter value.
-rw-r--r--sys/dev/pv/if_xnf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/dev/pv/if_xnf.c b/sys/dev/pv/if_xnf.c
index f6d6a9c9a72..64123cc6212 100644
--- a/sys/dev/pv/if_xnf.c
+++ b/sys/dev/pv/if_xnf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_xnf.c,v 1.37 2016/09/12 17:32:00 mikeb Exp $ */
+/* $OpenBSD: if_xnf.c,v 1.38 2016/09/12 18:55:18 mikeb Exp $ */
/*
* Copyright (c) 2015, 2016 Mike Belopuhov
@@ -511,16 +511,16 @@ static inline int
xnf_fragcount(struct mbuf *m_head)
{
struct mbuf *m;
- vaddr_t va;
+ vaddr_t va, va0;
int n = 0;
for (m = m_head; m != NULL; m = m->m_next) {
if (m->m_len == 0)
continue;
/* start of the buffer */
- for (va = mtod(m, vaddr_t);
+ for (va0 = va = mtod(m, vaddr_t);
/* does the buffer end on this page? */
- va + (PAGE_SIZE - (va & PAGE_MASK)) < va + m->m_len;
+ va + (PAGE_SIZE - (va & PAGE_MASK)) < va0 + m->m_len;
/* move on to the next page */
va += PAGE_SIZE - (va & PAGE_MASK))
n++;