summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2017-05-24 16:26:58 +0000
committerbluhm <bluhm@openbsd.org>2017-05-24 16:26:58 +0000
commit7448455134feb0f28fbe8e81b972ade6484195d4 (patch)
tree0d8d042c260bd54a4c28f4d49a74fcf9b4803612
parentSync NO_PID value from kernel header to tcpdump source. It is (diff)
downloadwireguard-openbsd-7448455134feb0f28fbe8e81b972ade6484195d4.tar.xz
wireguard-openbsd-7448455134feb0f28fbe8e81b972ade6484195d4.zip
When using "tcpdump proto 128" the filter never matched. A sign
expansion bug in bpf prevented protocols above 127. m_data is signed, bpf_mbuf_ldb() returns unsigned. bug report Matthias Pitzl; OK deraadt@ millert@
-rw-r--r--sys/net/bpf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index eba0501de7c..2d8ebb7bbda 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.162 2017/05/04 15:00:24 bluhm Exp $ */
+/* $OpenBSD: bpf.c,v 1.163 2017/05/24 16:26:58 bluhm Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -1824,6 +1824,7 @@ u_int32_t
bpf_mbuf_ldb(const void *m0, u_int32_t k, int *err)
{
const struct mbuf *m = m0;
+ u_int8_t v;
while (k >= m->m_len) {
k -= m->m_len;
@@ -1834,9 +1835,10 @@ bpf_mbuf_ldb(const void *m0, u_int32_t k, int *err)
return (0);
}
}
+ v = m->m_data[k];
*err = 0;
- return (m->m_data[k]);
+ return v;
}
u_int