(roken_getaddrinfo_hostspec): copy the correct length from `hostspec'.
based on a patch from Love <lha@s3.kth.se> git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8184 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -49,6 +49,7 @@ roken_getaddrinfo_hostspec(const char *hostspec,
|
|||||||
char portstr[NI_MAXSERV];
|
char portstr[NI_MAXSERV];
|
||||||
char host[MAXHOSTNAMELEN];
|
char host[MAXHOSTNAMELEN];
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
|
int hostspec_len;
|
||||||
|
|
||||||
struct hst {
|
struct hst {
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
@@ -81,9 +82,12 @@ roken_getaddrinfo_hostspec(const char *hostspec,
|
|||||||
char *end;
|
char *end;
|
||||||
|
|
||||||
port = strtol (p + 1, &end, 0);
|
port = strtol (p + 1, &end, 0);
|
||||||
|
hostspec_len = p - hostspec;
|
||||||
|
} else {
|
||||||
|
hostspec_len = strlen(hostspec);
|
||||||
}
|
}
|
||||||
snprintf (portstr, sizeof(portstr), "%u", port);
|
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);
|
return getaddrinfo (host, portstr, &hints, ai);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user