inet_ntop: do not compress single zeros in IPv6

Submitted by Arthur Jones on June 5, 2018, 11:51 p.m.

Details

Message ID 20180605235127.GA33151@mac_loaner.nbttech.com
State New
Series "inet_ntop: do not compress single zeros in IPv6"
Headers show

Commit Message

Arthur Jones June 5, 2018, 11:51 p.m.
glibc does not compress a single :0: to ::, we're not
doing anything wrong, but this change will make us more
compatible w/ glibc and fix a downstream testing issue
here: https://github.com/FRRouting/frr/issues/2375

I ran the "fix" through libc-test inet_pton.c on alpine
linux edge and it passed...

I'm not subscribed to the mailing list so please CC me...
---
 src/network/inet_ntop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/network/inet_ntop.c b/src/network/inet_ntop.c
index 14f9f4c4..4bfef2c5 100644
--- a/src/network/inet_ntop.c
+++ b/src/network/inet_ntop.c
@@ -36,7 +36,7 @@  const char *inet_ntop(int af, const void *restrict a0, char *restrict s, socklen
 			j = strspn(buf+i, ":0");
 			if (j>max) best=i, max=j;
 		}
-		if (max>2) {
+		if (max>3) {
 			buf[best] = buf[best+1] = ':';
 			memmove(buf+best+2, buf+best+max, i-best-max+1);
 		}