krb5 commit: Fix uninitialized variable bug in kdb_cpw.c

Greg Hudson ghudson at mit.edu
Fri Sep 5 17:06:56 EDT 2014


https://github.com/krb5/krb5/commit/9a6dc30d9105f0a3c2a209a2154660a0474b3499
commit 9a6dc30d9105f0a3c2a209a2154660a0474b3499
Author: Greg Hudson <ghudson at mit.edu>
Date:   Fri Sep 5 15:36:11 2014 -0400

    Fix uninitialized variable bug in kdb_cpw.c
    
    Now that add_key_rnd isn't looking up the TGT principal entry, it
    could use retval before initializing it if the loop runs for zero
    iterations.  Get rid of the add_key_rnd label (as it no longer does
    anything) and just return 0 after the loop ends.

 src/lib/kdb/kdb_cpw.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/lib/kdb/kdb_cpw.c b/src/lib/kdb/kdb_cpw.c
index a9ec509..fb07665 100644
--- a/src/lib/kdb/kdb_cpw.c
+++ b/src/lib/kdb/kdb_cpw.c
@@ -227,7 +227,7 @@ add_key_rnd(context, master_key, ks_tuple, ks_tuple_count, db_entry, kvno)
             continue;
 
         if ((retval = krb5_dbe_create_key_data(context, db_entry)))
-            goto add_key_rnd_err;
+            return retval;
 
         /* there used to be code here to extract the old key, and derive
            a new key from it.  Now that there's a unified prng, that isn't
@@ -236,7 +236,7 @@ add_key_rnd(context, master_key, ks_tuple, ks_tuple_count, db_entry, kvno)
         /* make new key */
         if ((retval = krb5_c_make_random_key(context, ks_tuple[i].ks_enctype,
                                              &key)))
-            goto add_key_rnd_err;
+            return retval;
 
         memset( &tmp_key_data, 0, sizeof(tmp_key_data));
         retval = krb5_dbe_encrypt_key_data(context, master_key, &key, NULL,
@@ -244,18 +244,17 @@ add_key_rnd(context, master_key, ks_tuple, ks_tuple_count, db_entry, kvno)
 
         krb5_free_keyblock_contents(context, &key);
         if( retval )
-            goto add_key_rnd_err;
+            return retval;
 
         /* Copy the result to ensure we use db_alloc storage. */
         retval = copy_key_data(context, &tmp_key_data,
                                &db_entry->key_data[db_entry->n_key_data - 1]);
         krb5_dbe_free_key_data_contents(context, &tmp_key_data);
         if (retval)
-            goto add_key_rnd_err;
+            return retval;
     }
 
-add_key_rnd_err:
-    return(retval);
+    return 0;
 }
 
 /* Construct a random explicit salt. */


More information about the cvs-krb5 mailing list