* t_kdb.c (do_testing): Invoke krb5_free_principal and
authorEzra Peisach <epeisach@mit.edu>
Mon, 19 Nov 2001 18:34:40 +0000 (18:34 +0000)
committerEzra Peisach <epeisach@mit.edu>
Mon, 19 Nov 2001 18:34:40 +0000 (18:34 +0000)
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

src/lib/kdb/ChangeLog
src/lib/kdb/t_kdb.c

index ecdc7d8b807ce0949b500dc8ac6f7724528c2094..74cac90484e1510015f1fb767459fdc62a23fd91 100644 (file)
@@ -1,3 +1,9 @@
+2001-11-19  Ezra Peisach  <epeisach@mit.edu>
+
+       * 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  <epeisach@mit.edu>
 
        * kdb_cpw.c (cleanup_key_data): Do not free NULL pointer.
index b49e09d6b26befda5980d5c224a515f0c1d467b4..ddb8258483a27d64aaa790320774d34b62b8cfcd 100644 (file)
@@ -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);