From: Bill Fenner Date: Sat, 4 Nov 2023 15:25:25 +0000 (-0700) Subject: Update LS-Ack printing to not run off the end of the packet X-Git-Tag: tcpdump-4.99.5~134 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/e16cfb27a85a5e4c4c5d2fdd72caf4aa0e9be451 Update LS-Ack printing to not run off the end of the packet (cherry picked from commit 4b4f7af5e8f3cbf06ffdefe8f24bcff089fd4ede) --- diff --git a/print-ospf.c b/print-ospf.c index e6bebed3..7aa00d39 100644 --- a/print-ospf.c +++ b/print-ospf.c @@ -1067,7 +1067,8 @@ ospf_decode_v2(netdissect_options *ndo, case OSPF_TYPE_LS_ACK: lshp = op->ospf_lsa.lsa_lshdr; - while (ospf_print_lshdr(ndo, lshp) != -1) { + while ((const u_char *)lshp < dataend) { + ospf_print_lshdr(ndo, lshp); ++lshp; } break; diff --git a/tests/TESTLIST b/tests/TESTLIST index 1bd08d1e..c91e1904 100644 --- a/tests/TESTLIST +++ b/tests/TESTLIST @@ -95,6 +95,7 @@ mpls-over-udp-v mpls-over-udp.pcap mpls-over-udp-v.out -v # OSPF tests ospf-gmpls ospf-gmpls.pcap ospf-gmpls.out -v ospf-nssa-bitnt ospf-nssa-bitnt.pcap ospf-nssa-bitnt.out -v +ospf-ack ospf-ack.pcap ospf-ack.out -v ospf3_ah-vv OSPFv3_with_AH.pcap ospf3_ah-vv.out -v -v ospf3_auth-vv ospf3_auth.pcapng ospf3_auth-vv.out -v -v ospf3_bc-vv OSPFv3_broadcast_adjacency.pcap ospf3_bc-vv.out -v -v diff --git a/tests/ospf-ack.out b/tests/ospf-ack.out new file mode 100644 index 00000000..324b805c --- /dev/null +++ b/tests/ospf-ack.out @@ -0,0 +1,9 @@ + 1 21:01:51.417510 IP (tos 0xc0, ttl 1, id 7082, offset 0, flags [DF], proto OSPF (89), length 84) + 1.0.1.2 > 224.0.0.5: OSPFv2, LS-Ack, length 64 + Router-ID 2.2.2.2, Area 0.0.0.1, Authentication Type: none (0) + Advertising Router 1.1.1.1, seq 0x80000002, age 46s, length 16 + Router LSA (1), LSA-ID: 1.1.1.1 + Options: [External, Demand Circuit] + Advertising Router 1.1.1.1, seq 0x80000001, age 43s, length 8 + Summary LSA (3), LSA-ID: 1.0.0.0 + Options: [External, Demand Circuit] diff --git a/tests/ospf-ack.pcap b/tests/ospf-ack.pcap new file mode 100644 index 00000000..87af347b Binary files /dev/null and b/tests/ospf-ack.pcap differ