When the (original) length is < length of the header, output example:
[length 39 < 40] (invalid)
(The IPv6 header must be 40 bytes in length.)
Place the 'length' test before the 'version' test.
Add a test file.
ND_PRINT(" ");
}
+ ND_ICHECK_ZU(length, <, sizeof (struct ip6_hdr));
if (IP6_VERSION(ip6) != 6) {
ND_PRINT("version error: %u != 6", IP6_VERSION(ip6));
return;
}
ND_TCHECK_SIZE(ip6);
- if (length < sizeof (struct ip6_hdr)) {
- ND_PRINT("truncated-ip6 %u", length);
- return;
- }
-
payload_len = GET_BE_U_2(ip6->ip6_plen);
/*
* RFC 1883 says:
return;
trunc:
nd_print_trunc(ndo);
+ return;
+
+invalid:
+ nd_print_invalid(ndo);
}
ipv6-srh-tlv-hmac-v ipv6-srh-tlv-hmac.pcap ipv6-srh-tlv-hmac-v.out -v
ipv6-srh-tlv-pad1-padn-5 ipv6-srh-tlv-pad1-padn-5.pcap ipv6-srh-tlv-pad1-padn-5.out
ipv6-srh-tlv-pad1-padn-5-v ipv6-srh-tlv-pad1-padn-5.pcap ipv6-srh-tlv-pad1-padn-5-v.out -v
+ipv6_invalid_length ipv6_invalid_length.pcap ipv6_invalid_length.out
# Loopback/CTP test case
loopback loopback.pcap loopback.out
--- /dev/null
+ 1 09:18:26.706088 IP6 [length 39 < 40] (invalid)