(krb5_sname_to_principal): remember to call freehostent

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6757 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1999-08-05 12:23:07 +00:00
parent 538358295d
commit aef4b5add5

View File

@@ -841,6 +841,7 @@ krb5_sname_to_principal (krb5_context context,
krb5_error_code ret; krb5_error_code ret;
char localhost[128]; char localhost[128];
char **realms, *host = NULL; char **realms, *host = NULL;
struct hostent *hp = NULL;
if(type != KRB5_NT_SRV_HST && type != KRB5_NT_UNKNOWN) if(type != KRB5_NT_SRV_HST && type != KRB5_NT_UNKNOWN)
return KRB5_SNAME_UNSUPP_NAMETYPE; return KRB5_SNAME_UNSUPP_NAMETYPE;
@@ -851,7 +852,6 @@ krb5_sname_to_principal (krb5_context context,
if(sname == NULL) if(sname == NULL)
sname = "host"; sname = "host";
if(type == KRB5_NT_SRV_HST) { if(type == KRB5_NT_SRV_HST) {
struct hostent *hp = NULL;
int error; int error;
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
@@ -866,18 +866,25 @@ krb5_sname_to_principal (krb5_context context,
if(type == KRB5_NT_SRV_HST) { if(type == KRB5_NT_SRV_HST) {
host = strdup(hostname); host = strdup(hostname);
if(host == NULL){ if(host == NULL){
if (hp != NULL)
freehostent (hp);
return ENOMEM; return ENOMEM;
} }
strlwr(host); strlwr(host);
hostname = host; hostname = host;
} }
ret = krb5_get_host_realm(context, hostname, &realms); ret = krb5_get_host_realm(context, hostname, &realms);
if(ret) if(ret) {
if (hp != NULL)
freehostent (hp);
return ret; return ret;
}
ret = krb5_make_principal(context, ret_princ, realms[0], sname, ret = krb5_make_principal(context, ret_princ, realms[0], sname,
hostname, NULL); hostname, NULL);
if(host) if(host)
free(host); free(host);
if (hp)
freehostent (hp);
krb5_free_host_realm(context, realms); krb5_free_host_realm(context, realms);
return ret; return ret;
} }