From bbb108c51953ee002bc918276d7975c2da1b2a1a Mon Sep 17 00:00:00 2001 From: Matthew Iselin Date: Thu, 26 May 2011 18:43:21 +1000 Subject: [PATCH] [ipv6] Make inet6_ntoa handle all-zero addresses properly Signed-off-by: Matthew Iselin Signed-off-by: Marty Connor --- src/net/ipv6.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/net/ipv6.c b/src/net/ipv6.c index 8d884dbe..5ce4e1ac 100644 --- a/src/net/ipv6.c +++ b/src/net/ipv6.c @@ -378,6 +378,13 @@ char * inet6_ntoa ( struct in6_addr in6 ) { static char buf[40]; uint16_t *bytes = ( uint16_t* ) &in6; size_t i = 0, longest = 0, tmp = 0, long_idx = ~0; + + /* ::0 */ + if ( IP6_EQUAL ( in6, ip6_none ) ) { + tmp = sprintf ( buf, "::0" ); + buf[tmp] = 0; + return buf; + } /* Determine the longest string of zeroes for zero-compression. */ for ( ; i < 8; i++ ) { -- 2.11.4.GIT