ICMPv6: Fix printing the Home Agent Address Discovery Reply Message

This change avoids incorrect truncation printing (" [|icmp6]") avoiding
any attempt to get an IPv6 address past the end of the packet data.
It also avoids a pointer overflow with a 32-bit build that stopped IPv6
addresses printing.
(When length is big, e.g. Jumbo Payload).
This commit is contained in:
Francois-Xavier Le Bail 2024-03-02 20:34:03 +01:00
parent f9ea99305f
commit 66dc8d7b96

View File

@ -1253,7 +1253,8 @@ icmp6_print(netdissect_options *ndo,
ND_PRINT(", id 0x%04x",
GET_BE_U_2(dp->icmp6_data16[0]));
cp = (const u_char *)dp + length;
cp = (const u_char *)dp +
ND_MIN(length, ND_BYTES_AVAILABLE_AFTER(dp));
p = (const u_char *)(dp + 1);
while (p < cp) {
ND_PRINT(", %s", GET_IP6ADDR_STRING(p));