summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordenis <denis@openbsd.org>2018-11-10 10:17:37 +0000
committerdenis <denis@openbsd.org>2018-11-10 10:17:37 +0000
commit4f6bb374518449c165a90e0f8eede434227be8d6 (patch)
tree45165b3c007f18f3fead25a3f37572c94fc997f1
parentRemove dead code (diff)
downloadwireguard-openbsd-4f6bb374518449c165a90e0f8eede434227be8d6.tar.xz
wireguard-openbsd-4f6bb374518449c165a90e0f8eede434227be8d6.zip
unbreak VLAN filtering
OK dlg@
-rw-r--r--lib/libpcap/gencode.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libpcap/gencode.c b/lib/libpcap/gencode.c
index d8b02985c72..e0e97aa4994 100644
--- a/lib/libpcap/gencode.c
+++ b/lib/libpcap/gencode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gencode.c,v 1.50 2018/11/09 20:36:04 denis Exp $ */
+/* $OpenBSD: gencode.c,v 1.51 2018/11/10 10:17:37 denis Exp $ */
/*
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
@@ -3364,6 +3364,11 @@ gen_vlan(vlan_num)
/*NOTREACHED*/
}
+ if (vlan_num > 4095) {
+ bpf_error("invalid VLAN number : %d", vlan_num);
+ /*NOTREACHED*/
+ }
+
/*
* Change the offsets to point to the type and data fields within
* the VLAN packet. This is somewhat of a kludge.
@@ -3395,7 +3400,7 @@ gen_vlan(vlan_num)
if (vlan_num >= 0) {
struct block *b1;
- b1 = gen_cmp(orig_nl, BPF_H, (bpf_int32)vlan_num);
+ b1 = gen_mcmp(orig_nl, BPF_H, (bpf_int32)vlan_num, 0x0FFF);
gen_and(b0, b1);
b0 = b1;
}