krb5 commit: Fix memory leak on error in KDC decrypt_2ndtkt()

Greg Hudson ghudson at mit.edu
Tue Mar 1 16:41:00 EST 2016


https://github.com/krb5/krb5/commit/a1faaa4d6a404e3103f45e639b8890c3b141dfe1
commit a1faaa4d6a404e3103f45e639b8890c3b141dfe1
Author: Greg Hudson <ghudson at mit.edu>
Date:   Thu Feb 25 11:19:17 2016 -0500

    Fix memory leak on error in KDC decrypt_2ndtkt()
    
    Make sure to release the server principal entry in the cleanup handler
    if it is not assigned to the output parameter.  Reported by Will
    Fiveash.
    
    ticket: 8362
    target_version: 1.14-next
    target_version: 1.13-next
    tags: pullup

 src/kdc/do_tgs_req.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/kdc/do_tgs_req.c b/src/kdc/do_tgs_req.c
index cb2cf35..a52c960 100644
--- a/src/kdc/do_tgs_req.c
+++ b/src/kdc/do_tgs_req.c
@@ -975,7 +975,7 @@ decrypt_2ndtkt(kdc_realm_t *kdc_active_realm, krb5_kdc_req *req,
                const char **status)
 {
     krb5_error_code retval;
-    krb5_db_entry *server;
+    krb5_db_entry *server = NULL;
     krb5_keyblock *key;
     krb5_kvno kvno;
     krb5_ticket *stkt;
@@ -1002,7 +1002,9 @@ decrypt_2ndtkt(kdc_realm_t *kdc_active_realm, krb5_kdc_req *req,
         goto cleanup;
     }
     *server_out = server;
+    server = NULL;
 cleanup:
+    krb5_db_free_principal(kdc_context, server);
     return retval;
 }
 


More information about the cvs-krb5 mailing list