krb5 commit: Fix leak in krb5_krcc_unparse_cred on error

Greg Hudson ghudson at MIT.EDU
Fri Aug 2 12:14:16 EDT 2013


https://github.com/krb5/krb5/commit/40d8ad25e2160583c6d74a10e7599253d3b292ce
commit 40d8ad25e2160583c6d74a10e7599253d3b292ce
Author: Greg Hudson <ghudson at mit.edu>
Date:   Fri Aug 2 11:37:40 2013 -0400

    Fix leak in krb5_krcc_unparse_cred on error
    
    Based on a patch from simo at redhat.com.

 src/lib/krb5/ccache/cc_keyring.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/lib/krb5/ccache/cc_keyring.c b/src/lib/krb5/ccache/cc_keyring.c
index 3828c59..55c7711 100644
--- a/src/lib/krb5/ccache/cc_keyring.c
+++ b/src/lib/krb5/ccache/cc_keyring.c
@@ -1913,7 +1913,7 @@ krb5_krcc_unparse_cred(krb5_context context, krb5_ccache id,
                        krb5_creds * creds, char **datapp, unsigned int *lenptr)
 {
     krb5_error_code kret;
-    char   *buf;
+    char *buf = NULL;
     krb5_krcc_bc bc;
 
     if (!creds || !datapp || !lenptr)
@@ -1963,9 +1963,11 @@ krb5_krcc_unparse_cred(krb5_context context, krb5_ccache id,
     /* Success! */
     *datapp = buf;
     *lenptr = bc.bpp - buf;
+    buf = NULL;
     kret = KRB5_OK;
 
 errout:
+    free(buf);
     return kret;
 }
 


More information about the cvs-krb5 mailing list