krb5 commit: Fix minor cleanup issue in file ccache
Greg Hudson
ghudson at mit.edu
Wed Nov 5 14:54:05 EST 2014
https://github.com/krb5/krb5/commit/16989828e9b9137b4f3c701962d838360f895636
commit 16989828e9b9137b4f3c701962d838360f895636
Author: Greg Hudson <ghudson at mit.edu>
Date: Tue Nov 4 10:13:11 2014 -0500
Fix minor cleanup issue in file ccache
If we fail to open the cache file in fcc_initialize, we could wind up
calling close(-1) which is harmless but incorrect. Avoid this by
initializing fd and conditionalizing its cleanup.
ticket: 8026
src/lib/krb5/ccache/cc_file.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/lib/krb5/ccache/cc_file.c b/src/lib/krb5/ccache/cc_file.c
index cd6fb9d..e220971 100644
--- a/src/lib/krb5/ccache/cc_file.c
+++ b/src/lib/krb5/ccache/cc_file.c
@@ -446,7 +446,7 @@ fcc_initialize(krb5_context context, krb5_ccache id, krb5_principal princ)
char i16buf[2], i32buf[4];
uint16_t fields_len;
ssize_t nwritten;
- int st, fd, flags, version;
+ int st, flags, version, fd = -1;
struct k5buf buf = EMPTY_K5BUF;
krb5_boolean file_locked = FALSE;
@@ -518,7 +518,8 @@ cleanup:
k5_buf_free(&buf);
if (file_locked)
krb5_unlock_file(context, fd);
- close(fd);
+ if (fd != -1)
+ close(fd);
k5_cc_mutex_unlock(context, &data->lock);
krb5_change_cache();
return ret;
More information about the cvs-krb5
mailing list