Index: print-ether.c =================================================================== RCS file: /cvs/src/usr.sbin/tcpdump/print-ether.c,v retrieving revision 1.31 diff -u -p -r1.31 print-ether.c --- print-ether.c 11 Jul 2016 00:27:50 -0000 1.31 +++ print-ether.c 25 Mar 2018 06:06:23 -0000 @@ -182,6 +182,7 @@ int ether_encap_print(u_short ethertype, const u_char *p, u_int length, u_int caplen) { + uint16_t vlan, pri, vid; recurse: extracted_ethertype = ethertype; @@ -221,10 +222,17 @@ recurse: case ETHERTYPE_QINQ: if (ethertype == ETHERTYPE_QINQ) printf("QinQ s"); - printf("vid %d pri %d%s", - ntohs(*(unsigned short*)p)&0xFFF, - ntohs(*(unsigned short*)p)>>13, - (ntohs(*(unsigned short*)p)&0x1000) ? " cfi " : " "); + + /* XXX caplen check */ + + vlan = ntohs(*(unsigned short*)p); + vid = vlan & 0xfff; + pri = vlan >> 13; + if (pri <= 1) + pri = !pri; + + printf("vid %d pri %d%s", vid, pri, + vlan & 0x1000 ? " cfi " : " "); ethertype = ntohs(*(unsigned short*)(p+2)); p += 4; length -= 4;