bullet-proofing the code -- if the data contents are NULL, it would coredump
authorRichard Basch <probe@mit.edu>
Fri, 22 Mar 1996 04:52:13 +0000 (04:52 +0000)
committerRichard Basch <probe@mit.edu>
Fri, 22 Mar 1996 04:52:13 +0000 (04:52 +0000)
(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
src/lib/kdb/decrypt_key.c

index 5aeeffc60af2d9fd58e44c5d6b5b5bc50a69b079..97fd97b77defd36a64d0a6c4cd9b5b1e1bd0fa78 100644 (file)
@@ -1,3 +1,8 @@
+Thu Mar 21 20:38:38 1996  Richard Basch  <basch@lehman.com>
+
+       * 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  <epeisach@kangaroo.mit.edu>
 
        * configure.in: Add KRB5_RUN_FLAGS
index 32891098d454f7ad387c52b0ad7916cd94c12ed6..2aa199ac7e2e0e081ba99c95db61be58e47bf77d 100644 (file)
@@ -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 */