]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
template_kem.c: Check outlen before dereferencing it
authorTomas Mraz <tomas@openssl.org>
Wed, 22 Jan 2025 15:55:35 +0000 (16:55 +0100)
committerTomas Mraz <tomas@openssl.org>
Fri, 24 Jan 2025 13:16:44 +0000 (14:16 +0100)
Fixes Coverity 163335316333561633357

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/26522)

providers/implementations/kem/template_kem.c

index 6100db353635d9e6011ffc5197a4ff3e0ea9f18d..e504d8709f67f800d2d8d1040d0f11b072fd656d 100644 (file)
@@ -143,7 +143,8 @@ static int template_encapsulate(void *vctx, unsigned char *out, size_t *outlen,
         *secretlen = 0; /* replace with real shared secret length */
 
     if (out == NULL) {
-        debug_print("encaps outlens set to %d and %d\n", *outlen, *secretlen);
+        if (outlen != NULL && secretlen != NULL)
+            debug_print("encaps outlens set to %d and %d\n", *outlen, *secretlen);
         return 1;
     }
 
@@ -164,7 +165,8 @@ static int template_decapsulate(void *vctx, unsigned char *out, size_t *outlen,
         *outlen = 0; /* replace with shared secret length */
 
     if (out == NULL) {
-        debug_print("decaps outlen set to %d \n", *outlen);
+        if (outlen != NULL)
+            debug_print("decaps outlen set to %d \n", *outlen);
         return 1;
     }