summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Kaduk <kaduk@mit.edu>2012-07-18 10:05:33 -0400
committerBen Kaduk <kaduk@mit.edu>2013-11-04 13:42:32 -0500
commitf7e434aa7ecb05a6ade5e3d4a435d25069acd5b2 (patch)
tree78baff77bde026e5991bc46b61e12daf0af511eb
parent51b5cef8387da33c2a61e5ebbf69a8702eece1d5 (diff)
downloadkrb5-f7e434aa7ecb05a6ade5e3d4a435d25069acd5b2.tar.gz
krb5-f7e434aa7ecb05a6ade5e3d4a435d25069acd5b2.tar.xz
krb5-f7e434aa7ecb05a6ade5e3d4a435d25069acd5b2.zip
Clean up stash file error handling
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.
-rw-r--r--src/lib/kdb/kdb_default.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/lib/kdb/kdb_default.c b/src/lib/kdb/kdb_default.c
index 9a7f757f9..82fa5c4a0 100644
--- a/src/lib/kdb/kdb_default.c
+++ b/src/lib/kdb/kdb_default.c
@@ -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) {