(krb5_sname_to_principal): use getaddrinfo

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7490 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1999-12-04 17:59:35 +00:00
parent 861698f953
commit 032cf94b5b

View File

@@ -876,23 +876,21 @@ krb5_sname_to_principal (krb5_context context,
sname = "host";
if(type == KRB5_NT_SRV_HST) {
int error;
struct addrinfo hints, *res;
char *host;
#ifdef HAVE_IPV6
if (hp == NULL)
hp = getipnodebyname (hostname, AF_INET6, 0, &error);
#endif
if (hp == NULL)
hp = getipnodebyname (hostname, AF_INET, 0, &error);
if(hp != NULL)
hostname = hp->h_name;
}
if(type == KRB5_NT_SRV_HST) {
host = strdup(hostname);
if(host == NULL){
if (hp != NULL)
freehostent (hp);
return ENOMEM;
memset (&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
error = getaddrinfo (hostname, NULL, &hints, &res);
if (error == 0) {
host = strdup (res->ai_canonname);
freeaddrinfo (res);
} else {
host = strdup (hostname);
}
if (host == NULL)
return ENOMEM;
strlwr(host);
hostname = host;
}