From 9ca269af63a5772d3e9c28c4e4893fafb306202e Mon Sep 17 00:00:00 2001 From: Pauli Date: Mon, 22 Mar 2021 12:49:50 +1000 Subject: [PATCH] apps: fix coverity 1451544: improper use of negative value Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14638) --- apps/speed.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/speed.c b/apps/speed.c index 0d7a9168c18..30e703632f1 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); -- 2.47.2