From 82cfb536fbf8a988be5d2aaa8baedf844422d4b2 Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Fri, 14 Apr 2000 01:31:29 +0000 Subject: [PATCH] (roken_getaddrinfo_hostspec): copy the correct length from `hostspec'. based on a patch from Love git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8184 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/roken/getaddrinfo_hostspec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/roken/getaddrinfo_hostspec.c b/lib/roken/getaddrinfo_hostspec.c index bfa236ff9..cafd06fcc 100644 --- a/lib/roken/getaddrinfo_hostspec.c +++ b/lib/roken/getaddrinfo_hostspec.c @@ -49,6 +49,7 @@ roken_getaddrinfo_hostspec(const char *hostspec, char portstr[NI_MAXSERV]; char host[MAXHOSTNAMELEN]; struct addrinfo hints; + int hostspec_len; struct hst { const char *prefix; @@ -81,9 +82,12 @@ roken_getaddrinfo_hostspec(const char *hostspec, char *end; port = strtol (p + 1, &end, 0); + hostspec_len = p - hostspec; + } else { + hostspec_len = strlen(hostspec); } snprintf (portstr, sizeof(portstr), "%u", port); - snprintf (host, sizeof(host), "%.*s", p - hostspec, hostspec); + snprintf (host, sizeof(host), "%.*s", hostspec_len, hostspec); return getaddrinfo (host, portstr, &hints, ai); }