]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Allow null keyblocks in IOV checksum functions 1382/head
authorGreg Hudson <ghudson@mit.edu>
Sun, 20 Oct 2024 06:09:26 +0000 (02:09 -0400)
committerGreg Hudson <ghudson@mit.edu>
Tue, 22 Oct 2024 18:31:22 +0000 (14:31 -0400)
Null keyblocks are allowed by the libk5crypto checksum functions when
the checksum type is not keyed.  However, krb5_c_make_checksum_iov()
and krb5_c_verify_checksum_iov() crash on null keyblock inputs because
they do not check before converting to krb5_key as their non-IOV
variants do.  Add the missing null checks.

ticket: 9146 (new)

src/lib/crypto/krb/make_checksum_iov.c
src/lib/crypto/krb/verify_checksum_iov.c

index 549180df515aa2da51f62f35165b7fe57c9d4cbc..84e98b141b9974d0eeb248f900cafc8c32e31ed9 100644 (file)
@@ -81,12 +81,14 @@ krb5_c_make_checksum_iov(krb5_context context,
                          krb5_crypto_iov *data,
                          size_t num_data)
 {
-    krb5_key key;
+    krb5_key key = NULL;
     krb5_error_code ret;
 
-    ret = krb5_k_create_key(context, keyblock, &key);
-    if (ret != 0)
-        return ret;
+    if (keyblock != NULL) {
+        ret = krb5_k_create_key(context, keyblock, &key);
+        if (ret != 0)
+            return ret;
+    }
     ret = krb5_k_make_checksum_iov(context, cksumtype, key, usage,
                                    data, num_data);
     krb5_k_free_key(context, key);
index fc76c0e269f4a44ff6f5f4291cf3ef25eddb3c31..47a25a93b4e8f2aec7b063e90f3e992aabcef385 100644 (file)
@@ -88,12 +88,14 @@ krb5_c_verify_checksum_iov(krb5_context context,
                            size_t num_data,
                            krb5_boolean *valid)
 {
-    krb5_key key;
+    krb5_key key = NULL;
     krb5_error_code ret;
 
-    ret = krb5_k_create_key(context, keyblock, &key);
-    if (ret != 0)
-        return ret;
+    if (keyblock != NULL) {
+        ret = krb5_k_create_key(context, keyblock, &key);
+        if (ret != 0)
+            return ret;
+    }
     ret = krb5_k_verify_checksum_iov(context, checksum_type, key, usage, data,
                                      num_data, valid);
     krb5_k_free_key(context, key);