summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauli <ppzgs1@gmail.com>2021-03-19 14:50:11 +1000
committerPauli <pauli@openssl.org>2021-04-08 08:49:27 +1000
commit48b05bb617e247a40b66c2ddd9326966000a3504 (patch)
tree738790676e6252830de0b0a5829d74f0d3c2b4b0
parent1002bb9ff0e35b4195586199222f9bad77837162 (diff)
evp: fix coverity 1451510: argument cannot be negative
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14620)
-rw-r--r--crypto/evp/e_rc4.c6
1 files changed, 5 insertions, 1 deletions
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;
}