[28644] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

krb5 commit: Fix minor cleanup issue in file ccache

daemon@ATHENA.MIT.EDU (Greg Hudson)
Wed Nov 5 14:55:16 2014

Date: Wed, 5 Nov 2014 14:54:05 -0500
From: Greg Hudson <ghudson@mit.edu>
Message-Id: <201411051954.sA5Js5Dx030059@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

https://github.com/krb5/krb5/commit/16989828e9b9137b4f3c701962d838360f895636
commit 16989828e9b9137b4f3c701962d838360f895636
Author: Greg Hudson <ghudson@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;
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post