]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Clean up stash file error handling
authorBen Kaduk <kaduk@mit.edu>
Wed, 18 Jul 2012 14:05:33 +0000 (10:05 -0400)
committerBen Kaduk <kaduk@mit.edu>
Mon, 4 Nov 2013 18:42:32 +0000 (13:42 -0500)
The comment previously failed to match the behavior. The intent was
that if we failed to write out the entire stash file into the
temporary location, we should remove the partial file.  However, the
code was actually checking whether the *real* stash file existed,
not whether the temporary one existed.

It is safe to always try to unlink the partial file, and not worry
about whether it already exists.

src/lib/kdb/kdb_default.c

index 9a7f757f965dc3d40052c9bbc90913fcc564ae4d..82fa5c4a0708bb6ff9111985bea434bec90b4883 100644 (file)
@@ -212,9 +212,8 @@ krb5_def_store_mkey_list(krb5_context       context,
     krb5_kt_close(context, kt);
 
     if (retval != 0) {
-        /* delete tmp keyfile if it exists and an error occurrs */
-        if (stat(keyfile, &stb) >= 0)
-            (void) unlink(tmp_ktpath);
+        /* Clean up by deleting the tmp keyfile if it exists. */
+        (void)unlink(tmp_ktpath);
     } else {
         /* rename original keyfile to original filename */
         if (rename(tmp_ktpath, keyfile) < 0) {