Wireshark-dev: [Wireshark-dev] IPv6 longest representation vs INET6_ADDRSTRLEN
From: Jakub Zawadzki <[email protected]>
Date: Thu, 5 May 2011 14:01:06 +0200

epan/ftypes/ftype_bytes.c:ipv6_repr_len() returns 39 which is length of: 

But it's common to have INET6_ADDRSTRLEN defined to 46, which I believe is 
length of "ffff:ffff:ffff:ffff:ffff:ffff:" + 1 byte for NUL.

IMHO when IPv4-mapping is used the longest address is:
::ffff: (22B)

Anyone knows inet_ntop(AF_INET6, ..) implementation which can actually use 46 bytes?

I'm asking because current code can lead to buffer overlow:
ipv6_to_repr() -> 
  ip6_to_str_buf((struct e_in6_addr *)fv->value.bytes->data, buf); ->
  inet_ntop(AF_INET6, (const guchar*)ad, buf, INET6_ADDRSTRLEN);

I'm planning to fix it by #define MAX_IPV6_STR_LEN inside to_str.h (like we do for other addresses),
but should it be 40 or 46 (or defined to INET6_ADDRSTRLEN)?