]> The Tcpdump Group git mirrors - tcpdump/commitdiff
DHCPv6: Update the snapend for nested DHCPv6 packets
authorFrancois-Xavier Le Bail <[email protected]>
Thu, 11 Feb 2021 16:46:02 +0000 (17:46 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Thu, 11 Feb 2021 17:23:22 +0000 (18:23 +0100)
Update the snapend to the end of the option before calling recursively
dhcp6_print() for the nested packet.
Other options may be present after the nested DHCPv6 packet.
This prevents that, in dhcp6_print(), for the nested DHCPv6 packet,
the remaining length < remaining caplen.

print-dhcp6.c

index dba13e9e483ef208241eb45f26853acbb77a0247..b6da2ffca4437634c2e7422da772cb2fcef4db0b 100644 (file)
@@ -410,7 +410,17 @@ dhcp6opt_print(netdissect_options *ndo,
                case DH6OPT_RELAY_MSG:
                        ND_PRINT(" (");
                        tp = (const u_char *)(dh6o + 1);
+                       /*
+                        * Update the snapend to the end of the option before
+                        * calling recursively dhcp6_print() for the nested
+                        * packet. Other options may be present after the
+                        * nested DHCPv6 packet. This prevents that, in
+                        * dhcp6_print(), for the nested DHCPv6 packet, the
+                        * remaining length < remaining caplen.
+                        */
+                       nd_push_snapend(ndo, tp + optlen);
                        dhcp6_print(ndo, tp, optlen);
+                       nd_pop_packet_info(ndo);
                        ND_PRINT(")");
                        break;
                case DH6OPT_AUTH: