aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorPauli <ppzgs1@gmail.com>2021-03-22 12:49:50 +1000
committerPauli <ppzgs1@gmail.com>2021-03-24 09:12:43 +1000
commit9ca269af63a5772d3e9c28c4e4893fafb306202e (patch)
treeb7e6007e075949cbd46fb38f9b01d05c7224bf65 /apps
parent66325793ccd670c1ad8104666932bdb43cec6e42 (diff)
downloadopenssl-9ca269af63a5772d3e9c28c4e4893fafb306202e.tar.gz
apps: fix coverity 1451544: improper use of negative value
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14638)
Diffstat (limited to 'apps')
-rw-r--r--apps/speed.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/apps/speed.c b/apps/speed.c
index 0d7a9168c1..30e703632f 100644
--- a/apps/speed.c
+++ b/apps/speed.c
@@ -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);