From 30b568091548ef97e199380a904f4fbcc5199156 Mon Sep 17 00:00:00 2001 From: Dennis Schafroth Date: Wed, 24 Apr 2013 20:56:58 +0200 Subject: [PATCH] Fix to work even when host name is shorter than IP number and on OS X in general, which nulls out host area --- src/getaddrinfo.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/getaddrinfo.c b/src/getaddrinfo.c index ed8ff70..1b09ad3 100644 --- a/src/getaddrinfo.c +++ b/src/getaddrinfo.c @@ -69,7 +69,8 @@ void perform_getaddrinfo(struct work *w) { struct addrinfo hints, *res; char host[512], *cp; - const char *port = 0; + char portbuf[512]; // very big ports + char *port = 0; int error; hints.ai_flags = 0; @@ -86,7 +87,8 @@ void perform_getaddrinfo(struct work *w) if ((cp = strrchr(host, ':'))) { *cp = '\0'; - port = cp + 1; + port = portbuf; + strncpy(port, cp + 1, sizeof(port)); } error = getaddrinfo(host, port ? port : "210", &hints, &res); if (error) -- 1.7.10.4