From b47ab4858c2620ecce3f4ee5e5afa86a2e8dd2be Mon Sep 17 00:00:00 2001 From: Richard Basch Date: Fri, 22 Mar 1996 04:52:13 +0000 Subject: [PATCH] bullet-proofing the code -- if the data contents are NULL, it would coredump (I discovered this one because of another bug) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7700 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/kdb/ChangeLog | 5 +++++ src/lib/kdb/decrypt_key.c | 26 ++++++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/lib/kdb/ChangeLog b/src/lib/kdb/ChangeLog index 5aeeffc60..97fd97b77 100644 --- a/src/lib/kdb/ChangeLog +++ b/src/lib/kdb/ChangeLog @@ -1,3 +1,8 @@ +Thu Mar 21 20:38:38 1996 Richard Basch + + * decrypt_key.c (krb5_dbekd_decrypt_key_data): bullet-proofing the + code -- if the data contents are NULL, do not coredump. + Mon Mar 18 21:46:39 1996 Ezra Peisach * configure.in: Add KRB5_RUN_FLAGS diff --git a/src/lib/kdb/decrypt_key.c b/src/lib/kdb/decrypt_key.c index 32891098d..2aa199ac7 100644 --- a/src/lib/kdb/decrypt_key.c +++ b/src/lib/kdb/decrypt_key.c @@ -40,7 +40,7 @@ krb5_dbekd_decrypt_key_data(context, eblock, key_data, keyblock, keysalt) krb5_keyblock * keyblock; krb5_keysalt * keysalt; { - krb5_error_code retval; + krb5_error_code retval = 0; krb5_int16 tmplen; krb5_octet * ptr; @@ -54,17 +54,19 @@ krb5_dbekd_decrypt_key_data(context, eblock, key_data, keyblock, keysalt) keyblock->length = 0; ptr = key_data->key_data_contents[0]; - krb5_kdb_decode_int16(ptr, tmplen); - ptr += 2; - keyblock->length = (int) tmplen; - if ((retval = krb5_decrypt(context, (krb5_pointer) ptr, - (krb5_pointer)keyblock->contents, - key_data->key_data_length[0] - 2, - eblock, 0))) { - krb5_xfree(keyblock->contents); - keyblock->contents = 0; - keyblock->length = 0; - return retval; + if (ptr) { + krb5_kdb_decode_int16(ptr, tmplen); + ptr += 2; + keyblock->length = (int) tmplen; + if ((retval = krb5_decrypt(context, (krb5_pointer) ptr, + (krb5_pointer)keyblock->contents, + key_data->key_data_length[0] - 2, + eblock, 0))) { + krb5_xfree(keyblock->contents); + keyblock->contents = 0; + keyblock->length = 0; + return retval; + } } /* Decode salt data */ -- 2.26.2