]> The Tcpdump Group git mirrors - tcpdump/commitdiff
ICMPv6: Add a length check
authorFrancois-Xavier Le Bail <[email protected]>
Sat, 23 Jun 2018 17:08:19 +0000 (19:08 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Sat, 23 Jun 2018 17:59:07 +0000 (19:59 +0200)
If the length is zero, it's invalid, print that.

Add a test with this case.

print-icmp6.c
tests/TESTLIST
tests/icmpv6-length-zero.out [new file with mode: 0644]
tests/icmpv6-length-zero.pcapng [new file with mode: 0644]

index 6ace80b59f0edd2f133832300a4ae8f6d4e9a43f..5fe0cc97ddbe441781ff8de762144e71c919764c 100644 (file)
@@ -1039,6 +1039,11 @@ icmp6_print(netdissect_options *ndo,
        oip = (const struct ip6_hdr *)(dp + 1);
        /* 'ep' points to the end of available data. */
        ep = ndo->ndo_snapend;
+       if (length == 0) {
+               ND_PRINT("ICMP6, length 0");
+               ND_PRINT("%s", istr);
+               return;
+       }
 
        if (ndo->ndo_vflag && !fragmented) {
                uint16_t sum, udp_sum;
index 002a963ac0a29e99a050e5fd018caaf4defa0417..d5ea9f0bec717979ecb7be3f594e1b81934abafd 100644 (file)
@@ -131,6 +131,7 @@ dvmrp               mrinfo_query.pcap       dvmrp.out
 # ICMPv6
 icmpv6          icmpv6.pcap             icmpv6.out      -vv
 icmpv6_opt24-v icmpv6_opt24.pcap       icmpv6_opt24-v.out      -v
+icmpv6-length-zero icmpv6-length-zero.pcapng icmpv6-length-zero.out
 
 # SPB tests
 spb                spb.pcap                spb.out
diff --git a/tests/icmpv6-length-zero.out b/tests/icmpv6-length-zero.out
new file mode 100644 (file)
index 0000000..d74e1d8
--- /dev/null
@@ -0,0 +1 @@
+IP6 fe80::25a:28ff:fe08:f150 > 6e02::41: ICMP6, length 0 (invalid)
diff --git a/tests/icmpv6-length-zero.pcapng b/tests/icmpv6-length-zero.pcapng
new file mode 100644 (file)
index 0000000..6831eff
Binary files /dev/null and b/tests/icmpv6-length-zero.pcapng differ