mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-23 10:04:05 +08:00
IP: Use ND_ICHECKMSG_ZU() to test the header length
Output example: [header length 16 < 20] (invalid) IP_HL() uses GET_U_1(), so there's no need for ND_TCHECK_*() beforehand. Add a test file.
This commit is contained in:
parent
4c39f476df
commit
eb957099ac
@ -341,12 +341,9 @@ ip_print(netdissect_options *ndo,
|
||||
ND_ICHECK_ZU(length, <, sizeof (struct ip));
|
||||
ND_ICHECKMSG_U("version", IP_V(ip), !=, 4);
|
||||
|
||||
ND_TCHECK_SIZE(ip);
|
||||
hlen = IP_HL(ip) * 4;
|
||||
if (hlen < sizeof (struct ip)) {
|
||||
ND_PRINT("bad-hlen %u", hlen);
|
||||
return;
|
||||
}
|
||||
ND_ICHECKMSG_ZU("header length", hlen, <, sizeof (struct ip));
|
||||
ND_TCHECK_SIZE(ip);
|
||||
|
||||
len = GET_BE_U_2(ip->ip_len);
|
||||
if (length < len)
|
||||
|
@ -348,6 +348,7 @@ dnssec-vv dnssec.pcap dnssec-vv.out -vv
|
||||
|
||||
#IPv4 tests
|
||||
ipv4_invalid_length ipv4_invalid_length.pcap ipv4_invalid_length.out -v
|
||||
ipv4_invalid_hdr_length ipv4_invalid_hdr_length.pcap ipv4_invalid_hdr_length.out -v
|
||||
|
||||
#IPv6 tests
|
||||
ipv6-bad-version ipv6-bad-version.pcap ipv6-bad-version.out
|
||||
|
1
tests/ipv4_invalid_hdr_length.out
Normal file
1
tests/ipv4_invalid_hdr_length.out
Normal file
@ -0,0 +1 @@
|
||||
1 08:57:44.621711 IP [header length 16 < 20] (invalid)
|
BIN
tests/ipv4_invalid_hdr_length.pcap
Normal file
BIN
tests/ipv4_invalid_hdr_length.pcap
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user