From 4711d26c11ba26dcf1b70ad5009884ea4c593195 Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Fri, 22 Jan 2010 16:09:19 +0100 Subject: [PATCH] Fix broken net_address_to_string(). --- src/network/network.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/network/network.c b/src/network/network.c index 431c8a5..b8b2e1f 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -526,12 +526,15 @@ const char* net_address_to_string(int af, const void* src, char* dst, socklen_t return NULL; #else - const char* address = inet_ntop(af, src, dst, cnt); - if (af == AF_INET6 && strncmp(address, "::ffff:", 7) == 0) /* IPv6 mapped IPv4 address. */ + if (inet_ntop(af, src, dst, cnt)) { - return &address[7]; + if (af == AF_INET6 && strncmp(dst, "::ffff:", 7) == 0) /* IPv6 mapped IPv4 address. */ + { + memmove(dst, dst + 7, cnt - 7); + } + return dst; } - return address; + return NULL; #endif }