summary refs log tree commit diff
path: root/sysdeps/posix/getaddrinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/posix/getaddrinfo.c')
-rw-r--r--sysdeps/posix/getaddrinfo.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 32b050ecf4..90af24fb61 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -287,6 +287,10 @@ static int gaih_inet(const char *name, const struct gaih_service *service,
     struct gaih_servtuple *st2;
     struct gaih_addrtuple *at2 = at;
     int j;
+#ifndef MAXHOSTNAMELEN
+# define MAXHOSTNAMELEN 128
+#endif /* MAXHOSTNAMELEN */
+    char buffer[MAXHOSTNAMELEN];
 
     while(at2) {
       if (req->ai_flags & AI_CANONNAME) {
@@ -308,9 +312,9 @@ static int gaih_inet(const char *name, const struct gaih_service *service,
 	    sizeof(struct in_addr), at2->family);
 #endif /* HOSTTABLE */
 
-	if (!h) {
-	  c = inet_ntop(at2->family, at2->addr, NULL, 0);
-	} else
+	if (!h)
+	  c = inet_ntop(at2->family, at2->addr, buffer, sizeof(buffer));
+	else
           c = h->h_name;
 
 	if (!c) {