summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2021-06-07 09:42:54 +1000
committerPauli <pauli@openssl.org>2021-06-08 19:32:17 +1000
commitdacb0d8f79debfe6b47f4b17ed6a51449dd7e484 (patch)
tree94c50e08e7b62e0c1d802bee2add8b26bc1c869b /crypto/evp
parent9428977994921d23b6aabc047298db3c55867709 (diff)
evp: fix Coverity 1485668 argument cannot be negative
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15635)
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/e_bf.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/evp/e_bf.c b/crypto/evp/e_bf.c
index 734e77f0a9..e3ff568757 100644
--- a/crypto/evp/e_bf.c
+++ b/crypto/evp/e_bf.c
@@ -38,7 +38,11 @@ IMPLEMENT_BLOCK_CIPHER(bf, ks, BF, EVP_BF_KEY, NID_bf, 8, 16, 8, 64,
static int bf_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc)
{
- BF_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_get_key_length(ctx), key);
+ int len = EVP_CIPHER_CTX_get_key_length(ctx);
+
+ if (len < 0)
+ return 0;
+ BF_set_key(&data(ctx)->ks, len, key);
return 1;
}