Fix afs_realm_of_cell5() to validate the return value of
krb5_get_host_realm
static char *afs_realm_of_cell5(krb5_context context, struct afsconf_cell *cellconfig)
{
- char ** krbrlms;
+ char ** krbrlms = 0;
static char krbrlm[REALM_SZ+1];
krb5_error_code status;
status = krb5_get_host_realm( context, cellconfig->hostName[0], &krbrlms );
- if(krbrlms && krbrlms[0])
+ if (status == 0 && krbrlms && krbrlms[0]) {
strcpy(krbrlm, krbrlms[0]);
- else {
+ } else {
strcpy(krbrlm, cellconfig->name);
strupr(krbrlm);
}
- if(krbrlms)
+ if (krbrlms)
krb5_free_host_realm( context, krbrlms );
return krbrlm;