[gPXE-devel] [PATCH 02/31] [ipv6] fix inet6_ntoa to handle all-zero addresses properly

matthew at theiselins.net matthew at theiselins.net
Fri Jul 8 10:28:11 EDT 2011


From: Matthew Iselin <matthew at theiselins.net>

Signed-off-by: Matthew Iselin <matthew at theiselins.net>
---
 src/net/ipv6.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/net/ipv6.c b/src/net/ipv6.c
index 8d884db..5ce4e1a 100644
--- a/src/net/ipv6.c
+++ b/src/net/ipv6.c
@@ -379,6 +379,13 @@ char * inet6_ntoa ( struct in6_addr in6 ) {
 	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++ ) {
 		if ( !bytes[i] )
-- 
1.7.2.5



More information about the gPXE-devel mailing list