]> The Tcpdump Group git mirrors - libpcap/commit
Require "link proto" argument value to be within range. 1502/head
authorDenis Ovsienko <[email protected]>
Sun, 6 Apr 2025 14:06:25 +0000 (15:06 +0100)
committerDenis Ovsienko <[email protected]>
Mon, 7 Apr 2025 08:25:46 +0000 (09:25 +0100)
commitf451c273d8ed3e903722ee755085a106bb9f1db9
tree3741d038eaa5971bf43dd29dbd17c65319a234cd
parent444bcd430b7fd6f7e3e7ef6f56861d7a5c6b3969
Require "link proto" argument value to be within range.

pcap_compile() fails to reject invalid link-layer protocol numbers, for
example:

$ filtertest EN10MB 'link proto 0x12345678'
(000) ldh      [12]
(001) jeq      #0x12345678      jt 2 jf 3
(002) ret      #262144
(003) ret      #0
(loads a 16-bit value and compares it with a 32-bit value)

$ filtertest EN10MB 'link proto 1200'
(000) ldh      [12]
(001) jgt      #0x5dc           jt 5 jf 2
(002) ldb      [14]
(003) jeq      #0x4b0           jt 4 jf 5
(004) ret      #262144
(005) ret      #0
(loads an 8-bit value and compares it with a 16-bit value)

Fixing this failure to fail requires well more than one check because
the valid range and values of a protocol number are specific to the DLT
and/or the protocol, also in some cases there is a mapping between
different protocols.  Add a reject filter test for every new check.
CHANGES
gencode.c
testprogs/TESTrun