]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Check AEAD additional data existence before use
authorAram Sargsyan <aram@isc.org>
Wed, 15 Jul 2026 13:14:42 +0000 (13:14 +0000)
committerAram Sargsyan <aram@isc.org>
Tue, 21 Jul 2026 10:09:21 +0000 (10:09 +0000)
The isc_crypto_aead_open() and isc_crypto_aead_seal() functions
in ossl3.c didn't check if 'additional_data' exists before using
it. The checks were in place in the ossl1_1.c implementation. Use
the same conditions in the ossl3.c implementation too.

lib/isc/crypto/ossl3.c

index 3473502badc3c037fbba72f075c092c10889c21b..716786260d7dabd4559200a9050f80196b2ed767 100644 (file)
@@ -533,10 +533,13 @@ isc_crypto_aead_seal(isc_crypto_aead_t *aead, isc_constregion_t nonce,
                CLEANUP(ISC_R_CRYPTOFAILURE);
        }
 
-       if (EVP_EncryptUpdate(aead, NULL, &len, additional_data.base,
-                             additional_data.length) != 1)
-       {
-               CLEANUP(ISC_R_CRYPTOFAILURE);
+       if (additional_data.base != NULL) {
+               INSIST(additional_data.length != 0);
+               if (EVP_EncryptUpdate(aead, NULL, &len, additional_data.base,
+                                     additional_data.length) != 1)
+               {
+                       CLEANUP(ISC_R_CRYPTOFAILURE);
+               }
        }
 
        len = out.length;
@@ -599,10 +602,13 @@ isc_crypto_aead_open(isc_crypto_aead_t *aead, isc_constregion_t nonce,
                CLEANUP(ISC_R_CRYPTOFAILURE);
        }
 
-       if (EVP_DecryptUpdate(aead, NULL, &len, additional_data.base,
-                             additional_data.length) != 1)
-       {
-               CLEANUP(ISC_R_CRYPTOFAILURE);
+       if (additional_data.base != NULL) {
+               INSIST(additional_data.length != 0);
+               if (EVP_DecryptUpdate(aead, NULL, &len, additional_data.base,
+                                     additional_data.length) != 1)
+               {
+                       CLEANUP(ISC_R_CRYPTOFAILURE);
+               }
        }
 
        len = out.length;