Fixes a heap overflow found with American Fuzzy Lop by Hanno Böck.
void
ipN_print(netdissect_options *ndo, register const u_char *bp, register u_int length)
{
void
ipN_print(netdissect_options *ndo, register const u_char *bp, register u_int length)
{
- struct ip hdr;
-
- if (length < 4) {
ND_PRINT((ndo, "truncated-ip %d", length));
return;
}
ND_PRINT((ndo, "truncated-ip %d", length));
return;
}
- memcpy (&hdr, bp, 4);
- switch (IP_V(&hdr)) {
- case 4:
+
+ ND_TCHECK(*bp);
+ switch (*bp & 0xF0) {
+ case 0x40:
ip_print (ndo, bp, length);
ip_print (ndo, bp, length);
ip6_print (ndo, bp, length);
ip6_print (ndo, bp, length);
- ND_PRINT((ndo, "unknown ip %d", IP_V(&hdr)));
- return;
+ ND_PRINT((ndo, "unknown ip %d", (*bp & 0xF0) >> 4));
+ break;
+ return;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return;
bfd-raw-auth-md5-v bfd-raw-auth-md5.pcap bfd-raw-auth-md5-v.out -t -v
bfd-raw-auth-sha1 bfd-raw-auth-sha1.pcap bfd-raw-auth-sha1.out -t
bfd-raw-auth-sha1-v bfd-raw-auth-sha1.pcap bfd-raw-auth-sha1-v.out -t -v
bfd-raw-auth-md5-v bfd-raw-auth-md5.pcap bfd-raw-auth-md5-v.out -t -v
bfd-raw-auth-sha1 bfd-raw-auth-sha1.pcap bfd-raw-auth-sha1.out -t
bfd-raw-auth-sha1-v bfd-raw-auth-sha1.pcap bfd-raw-auth-sha1-v.out -t -v
+
+# bad packets from Hanno Böck
+heap-overflow-1 heap-overflow-1.pcap heap-overflow-1.out -t -v -n