(krb5_expand_hostname): handle ai_canonname not being set
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7607 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -35,6 +35,17 @@
|
|||||||
|
|
||||||
RCSID("$Id$");
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
static krb5_error_code
|
||||||
|
copy_hostname(krb5_context context,
|
||||||
|
const char *orig_hostname,
|
||||||
|
char **new_hostname)
|
||||||
|
{
|
||||||
|
*new_hostname = strdup (orig_hostname);
|
||||||
|
if (*new_hostname == NULL)
|
||||||
|
return ENOMEM;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
krb5_expand_hostname (krb5_context context,
|
krb5_expand_hostname (krb5_context context,
|
||||||
const char *orig_hostname,
|
const char *orig_hostname,
|
||||||
@@ -47,11 +58,11 @@ krb5_expand_hostname (krb5_context context,
|
|||||||
hints.ai_flags = AI_CANONNAME;
|
hints.ai_flags = AI_CANONNAME;
|
||||||
|
|
||||||
error = getaddrinfo (orig_hostname, NULL, &hints, &ai);
|
error = getaddrinfo (orig_hostname, NULL, &hints, &ai);
|
||||||
if (error) {
|
if (error)
|
||||||
*new_hostname = strdup (orig_hostname);
|
return copy_hostname (context, orig_hostname, new_hostname);
|
||||||
if (*new_hostname == NULL)
|
if (ai->ai_canonname == NULL) {
|
||||||
return ENOMEM;
|
freeaddrinfo (ai);
|
||||||
return 0;
|
return copy_hostname (context, orig_hostname, new_hostname);
|
||||||
}
|
}
|
||||||
*new_hostname = strdup(ai->ai_canonname);
|
*new_hostname = strdup(ai->ai_canonname);
|
||||||
freeaddrinfo (ai);
|
freeaddrinfo (ai);
|
||||||
|
Reference in New Issue
Block a user