From 48b05bb617e247a40b66c2ddd9326966000a3504 Mon Sep 17 00:00:00 2001 From: Pauli Date: Fri, 19 Mar 2021 14:50:11 +1000 Subject: evp: fix coverity 1451510: argument cannot be negative Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/14620) --- crypto/evp/e_rc4.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crypto/evp') diff --git a/crypto/evp/e_rc4.c b/crypto/evp/e_rc4.c index 10b83aea6d..94107c72c3 100644 --- a/crypto/evp/e_rc4.c +++ b/crypto/evp/e_rc4.c @@ -75,7 +75,11 @@ const EVP_CIPHER *EVP_rc4_40(void) static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { - RC4_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), key); + int keylen; + + if ((keylen = EVP_CIPHER_CTX_key_length(ctx)) <= 0) + return 0; + RC4_set_key(&data(ctx)->ks, keylen, key); return 1; } -- cgit v1.2.3