From: Dennis Schafroth Date: Wed, 24 Apr 2013 18:56:58 +0000 (+0200) Subject: Fix to work even when host name is shorter than IP number and on OS X in general... X-Git-Tag: v1.6.30~10 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=30b568091548ef97e199380a904f4fbcc5199156;p=pazpar2-moved-to-github.git Fix to work even when host name is shorter than IP number and on OS X in general, which nulls out host area --- 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)