'tcpdump vlan $vlan_number' will not return anything if priority is not 0.

Fix that by not comparing vlan number against priority.
Also deny usage of vlan number greater than 4095 while at it.

Index: gencode.c
===================================================================
RCS file: /cvs/src/lib/libpcap/gencode.c,v
retrieving revision 1.50
diff -u -p -r1.50 gencode.c
--- gencode.c   9 Nov 2018 20:36:04 -0000       1.50
+++ gencode.c   10 Nov 2018 08:59:52 -0000
@@ -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;
        }

Reply via email to