From 5c8e69267b9ae919e55eee4b79580224111bc3ba Mon Sep 17 00:00:00 2001 From: Arthur Jones Date: Tue, 5 Jun 2018 16:51:27 -0700 Subject: inet_ntop: do not compress single zeros in IPv6 maintainer's note: this change is for conformance with RFC 5952, 4.2.2, which explicitly forbids use of :: to shorten a single 16-bit 0 field when producing the canonical text representation for an IPv6 address. fixes a test failure reported by Philip Homburg, who also submitted a patch, but this fix is simpler and should produce smaller code. --- src/network/inet_ntop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/network') 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); } -- cgit v1.2.1