aboutsummaryrefslogtreecommitdiff
path: root/src/port/getaddrinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/port/getaddrinfo.c')
-rw-r--r--src/port/getaddrinfo.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/port/getaddrinfo.c b/src/port/getaddrinfo.c
index f867744eee2..807f5bd56d7 100644
--- a/src/port/getaddrinfo.c
+++ b/src/port/getaddrinfo.c
@@ -388,16 +388,14 @@ getnameinfo(const struct sockaddr * sa, int salen,
if (node)
{
- int ret = -1;
-
if (sa->sa_family == AF_INET)
{
- char *p;
-
- p = inet_ntoa(((struct sockaddr_in *) sa)->sin_addr);
- ret = snprintf(node, nodelen, "%s", p);
+ if (inet_net_ntop(AF_INET, ((struct sockaddr_in *) sa)->sin_addr,
+ sa->sa_family == AF_INET ? 32 : 128,
+ node, nodelen) == NULL)
+ return EAI_MEMORY;
}
- if (ret == -1 || ret > nodelen)
+ else
return EAI_MEMORY;
}