]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
apps: fix coverity 1451544: improper use of negative value
authorPauli <ppzgs1@gmail.com>
Mon, 22 Mar 2021 02:49:50 +0000 (12:49 +1000)
committerPauli <ppzgs1@gmail.com>
Tue, 23 Mar 2021 23:12:43 +0000 (09:12 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14638)

apps/speed.c

index 0d7a9168c182f062853648575211603472b2b288..30e703632f1b5c0e49019c1ea92b118b039ed895 100644 (file)
@@ -3613,7 +3613,10 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher, int lengths_single,
     ctx = EVP_CIPHER_CTX_new();
     EVP_EncryptInit_ex(ctx, evp_cipher, NULL, NULL, no_iv);
 
-    keylen = EVP_CIPHER_CTX_key_length(ctx);
+    if ((keylen = EVP_CIPHER_CTX_key_length(ctx)) < 0) {
+        BIO_printf(bio_err, "Impossible negative key length: %d\n", keylen);
+        return;
+    }
     key = app_malloc(keylen, "evp_cipher key");
     EVP_CIPHER_CTX_rand_key(ctx, key);
     EVP_EncryptInit_ex(ctx, NULL, NULL, key, NULL);