krb5_get_server_rcache had some dead (and incorrect) code for cleaning
authorGreg Hudson <ghudson@mit.edu>
Fri, 30 Jan 2009 21:25:40 +0000 (21:25 +0000)
committerGreg Hudson <ghudson@mit.edu>
Fri, 30 Jan 2009 21:25:40 +0000 (21:25 +0000)
up the rcache on failure.  Fix the cleanup code and make use of it.

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

src/lib/krb5/krb/srv_rcache.c

index 9da6d45ff0ddbf74f892ffb48268cf8d47cf4cdc..7d6b68a7eeb9b7aa79d7f52b2753ec367e078e7e 100644 (file)
@@ -71,21 +71,13 @@ krb5_get_server_rcache(krb5_context context, const krb5_data *piece,
        return ENOMEM;
 
     retval = krb5_rc_resolve_full(context, &rcache, cachename);
-    if (retval) {
-       rcache = 0;
+    if (retval)
        goto cleanup;
-    }
 
-    /*
-     * First try to recover the replay cache; if that doesn't work,
-     * initialize it.
-     */
-    retval = krb5_rc_recover_or_initialize(context, rcache, context->clockskew);
-    if (retval) {
-       krb5_rc_close(context, rcache);
-       rcache = 0;
+    retval = krb5_rc_recover_or_initialize(context, rcache,
+                                          context->clockskew);
+    if (retval)
        goto cleanup;
-    }
 
     *rcptr = rcache;
     rcache = 0;
@@ -93,7 +85,7 @@ krb5_get_server_rcache(krb5_context context, const krb5_data *piece,
 
 cleanup:
     if (rcache)
-       free(rcache);
+       krb5_rc_close(context, rcache);
     if (cachename)
        free(cachename);
     return retval;