From: Francois-Xavier Le Bail Date: Sun, 27 Aug 2023 09:20:58 +0000 (+0200) Subject: IPv6: Print some header fields, even if the header is incomplete X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/f6ae03e29956d0fe4e4d611fe01a60d67f3088b3 IPv6: Print some header fields, even if the header is incomplete Add a test file with a 39-byte header. Moreover: Fix an indentation. --- diff --git a/print-ip6.c b/print-ip6.c index 827151eb..460795c7 100644 --- a/print-ip6.c +++ b/print-ip6.c @@ -249,7 +249,6 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length) ND_ICHECK_ZU(length, <, sizeof (struct ip6_hdr)); ND_ICHECKMSG_U("version", IP6_VERSION(ip6), !=, 6); - ND_TCHECK_SIZE(ip6); payload_len = GET_BE_U_2(ip6->ip6_plen); /* * RFC 1883 says: @@ -301,6 +300,7 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length) nh, payload_len); } + ND_TCHECK_SIZE(ip6); /* * Cut off the snapshot length to the end of the IP payload. @@ -328,7 +328,7 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length) nh != IPPROTO_TCP && nh != IPPROTO_UDP && nh != IPPROTO_DCCP && nh != IPPROTO_SCTP) { ND_PRINT("%s > %s: ", GET_IP6ADDR_STRING(ip6->ip6_src), - GET_IP6ADDR_STRING(ip6->ip6_dst)); + GET_IP6ADDR_STRING(ip6->ip6_dst)); } switch (nh) { diff --git a/tests/TESTLIST b/tests/TESTLIST index 8cfd3442..73b9aef8 100644 --- a/tests/TESTLIST +++ b/tests/TESTLIST @@ -362,6 +362,7 @@ ipv6-srh-tlv-pad1-padn-5-v ipv6-srh-tlv-pad1-padn-5.pcap ipv6-srh-tlv-pad1-padn- ipv6_invalid_length ipv6_invalid_length.pcap ipv6_invalid_length.out ipv6_invalid_length_2 ipv6_invalid_length_2.pcap ipv6_invalid_length_2.out -v ipv6_jumbogram_invalid_length ipv6_jumbogram_invalid_length.pcap ipv6_jumbogram_invalid_length.out -v +ipv6_39_byte_header ipv6_39_byte_header.pcap ipv6_39_byte_header.out -v # Loopback/CTP test case loopback loopback.pcap loopback.out diff --git a/tests/ipv6_39_byte_header.out b/tests/ipv6_39_byte_header.out new file mode 100644 index 00000000..17e936ad --- /dev/null +++ b/tests/ipv6_39_byte_header.out @@ -0,0 +1 @@ + 1 07:30:59.044880 IP6 (flowlabel 0x74111, hlim 64, next-header UDP (17) payload length: 64) [|ip6] diff --git a/tests/ipv6_39_byte_header.pcap b/tests/ipv6_39_byte_header.pcap new file mode 100644 index 00000000..b0a51b81 Binary files /dev/null and b/tests/ipv6_39_byte_header.pcap differ