Check before fetching the length from the included packet's IPv4 header.
This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.
Add a test using the capture file supplied by the reporter(s), modified
so the capture file won't be rejected as an invalid capture.
ND_PRINT((ndo, "\n\t"));
ip = (const struct ip *)bp;
snapend_save = ndo->ndo_snapend;
+ ND_TCHECK_16BITS(&ip->ip_len);
ip_print(ndo, bp, EXTRACT_16BITS(&ip->ip_len));
ndo->ndo_snapend = snapend_save;
}
# bad packets from Bhargava Shastry
lldp_asan lldp_asan.pcap lldp_asan.out -v
+extract_read2_asan extract_read2_asan.pcap extract_read2_asan.out -v
# RTP tests
# fuzzed pcap
--- /dev/null
+IP (tos 0x14, id 1, offset 0, flags [none], proto ICMP (1), length 512, options (unknown 3,unknown 3,unknown 3 [bad length 3]), bad cksum 3ff (->b4bd)!)
+ 240.25.0.0 > 3.3.3.3: ICMP source quench, length 484
+ [|icmp]