From: Ezra Peisach Date: Mon, 19 Nov 2001 18:34:40 +0000 (+0000) Subject: * t_kdb.c (do_testing): Invoke krb5_free_principal and X-Git-Tag: krb5-1.3-alpha1~947 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=64b0fc3a72ce9de1176ab84be5d408a35ff143d9;p=krb5.git * t_kdb.c (do_testing): Invoke krb5_free_principal and krb5_free_keyblock_contents on master key to prevent minor memory leak. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13994 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/kdb/ChangeLog b/src/lib/kdb/ChangeLog index ecdc7d8b8..74cac9048 100644 --- a/src/lib/kdb/ChangeLog +++ b/src/lib/kdb/ChangeLog @@ -1,3 +1,9 @@ +2001-11-19 Ezra Peisach + + * t_kdb.c (do_testing): Invoke krb5_free_principal and + krb5_free_keyblock_contents on master key to prevent minor memory + leak. + 2001-10-30 Ezra Peisach * kdb_cpw.c (cleanup_key_data): Do not free NULL pointer. diff --git a/src/lib/kdb/t_kdb.c b/src/lib/kdb/t_kdb.c index b49e09d6b..ddb825848 100644 --- a/src/lib/kdb/t_kdb.c +++ b/src/lib/kdb/t_kdb.c @@ -474,6 +474,7 @@ do_testing(db, passes, verbose, timing, rcases, check, save_db, dontclean, krb5_context kcontext; char *op, *linkage, *oparg; krb5_principal master_princ; + int master_princ_set = 0; char *mkey_name; char *realm; char *mkey_fullname; @@ -502,6 +503,8 @@ do_testing(db, passes, verbose, timing, rcases, check, save_db, dontclean, oparg = ""; crflags = hash ? KRB5_KDB_CREATE_HASH : KRB5_KDB_CREATE_BTREE; + memset(&master_keyblock, 0, sizeof(master_keyblock)); + /* Set up some initial context */ op = "initializing krb5"; kret = krb5_init_context(&kcontext); @@ -523,10 +526,14 @@ do_testing(db, passes, verbose, timing, rcases, check, save_db, dontclean, &mkey_fullname, &master_princ))) goto goodbye; + master_princ_set = 1; if (verbose) fprintf(stdout, "%s: Initializing '%s', master key is '%s'\n", programname, db, mkey_fullname); + free(mkey_fullname); + mkey_fullname = 0; + op = "salting master key"; if ((kret = krb5_principal2salt(kcontext, master_princ, &salt_data))) goto goodbye; @@ -862,6 +869,9 @@ do_testing(db, passes, verbose, timing, rcases, check, save_db, dontclean, } goodbye: + if(master_princ_set) { + krb5_free_principal(kcontext, master_princ); + } if (kret) fprintf(stderr, "%s: error while %s %s%s(%s)\n", programname, op, linkage, oparg, error_message(kret)); @@ -976,6 +986,7 @@ do_testing(db, passes, verbose, timing, rcases, check, save_db, dontclean, } } + krb5_free_keyblock_contents(kcontext, &master_keyblock); krb5_free_context(kcontext); return((kret) ? 1 : 0);