From fd1fce9080774cb7a678fb445f0386e623d038dd Mon Sep 17 00:00:00 2001 From: Francois-Xavier Le Bail Date: Sun, 27 Aug 2023 11:20:58 +0200 Subject: [PATCH] IPv6: Print some header fields, even if the header is incomplete Add a test file with a 39-byte header. Moreover: Fix an indentation. (cherry picked from commit f6ae03e29956d0fe4e4d611fe01a60d67f3088b3) --- print-ip6.c | 4 ++-- tests/TESTLIST | 1 + tests/ipv6_39_byte_header.out | 1 + tests/ipv6_39_byte_header.pcap | Bin 0 -> 79 bytes 4 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 tests/ipv6_39_byte_header.out create mode 100644 tests/ipv6_39_byte_header.pcap diff --git a/print-ip6.c b/print-ip6.c index 827151eb3..460795c74 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 f66afa1e5..3b4afec2d 100644 --- a/tests/TESTLIST +++ b/tests/TESTLIST @@ -316,6 +316,7 @@ ipv6_jumbogram_1 ipv6_jumbogram_1.pcap ipv6_jumbogram_1.out -ev 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 000000000..17e936ada --- /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 0000000000000000000000000000000000000000..b0a51b8152a9997502378cfd6f4b47fcd88eba54 GIT binary patch literal 79 zcmca|c+)~A1{MYcU}0bcayCc2NC{Zaz@QFfmjUsCYfWa%+8=xu*~TtzyPLr7D9GR- U=%B{Br@=sg5v;xEGUqup0L}apHUIzs literal 0 HcmV?d00001