In krb5_kt_resolve, ensure that the output parameter is set to NULL on
authorGreg Hudson <ghudson@mit.edu>
Thu, 30 Apr 2009 17:49:28 +0000 (17:49 +0000)
committerGreg Hudson <ghudson@mit.edu>
Thu, 30 Apr 2009 17:49:28 +0000 (17:49 +0000)
failure even if the underlying resolver doesn't do that properly.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22297 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/keytab/ktbase.c

index a764cc593980eec1a6f9622d1baacf80af0cdc69..b99bee4035d43fd74aa5c80dcf4adc6b442bf9c8 100644 (file)
@@ -166,11 +166,13 @@ krb5_kt_resolve (krb5_context context, const char *name, krb5_keytab *ktid)
     unsigned int pfxlen;
     const char *cp, *resid;
     krb5_error_code err = 0;
-    
+    krb5_keytab id;
+
+    *ktid = NULL;
+
     cp = strchr (name, ':');
-    if (!cp) {
-           return (*krb5_kt_dfl_ops.resolve)(context, name, ktid);
-    }
+    if (!cp)
+       return (*krb5_kt_dfl_ops.resolve)(context, name, ktid);
 
     pfxlen = cp - name;
 
@@ -209,7 +211,9 @@ krb5_kt_resolve (krb5_context context, const char *name, krb5_keytab *ktid)
     k5_mutex_unlock(&kt_typehead_lock);
     for (; tlist; tlist = tlist->next) {
        if (strcmp (tlist->ops->prefix, pfx) == 0) {
-           err = (*tlist->ops->resolve)(context, resid, ktid);
+           err = (*tlist->ops->resolve)(context, resid, &id);
+           if (!err)
+               *ktid = id;
            goto cleanup;
        }
     }