[ipv6] Make inet6_ntoa handle all-zero addresses properly
authorMatthew Iselin <matthew@theiselins.net>
Thu, 26 May 2011 08:43:21 +0000 (18:43 +1000)
committerMarty Connor <mdc@etherboot.org>
Tue, 19 Jul 2011 00:33:12 +0000 (20:33 -0400)
Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
src/net/ipv6.c

index 8d884db..5ce4e1a 100644 (file)
@@ -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++ ) {