diff options
author | Pauli <ppzgs1@gmail.com> | 2021-03-19 14:50:28 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-04-08 08:49:27 +1000 |
commit | 3bbc7b562abf4ca3221d8762fe3f749024936281 (patch) | |
tree | db56fd74f0cc9a4f9fc9b6d372c029bbba6f2f52 | |
parent | 48b05bb617e247a40b66c2ddd9326966000a3504 (diff) |
evp: fix coverity 1451509: 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_hmac_md5.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/evp/e_rc4_hmac_md5.c b/crypto/evp/e_rc4_hmac_md5.c index 098aa3ee1b..8bc1da6323 100644 --- a/crypto/evp/e_rc4_hmac_md5.c +++ b/crypto/evp/e_rc4_hmac_md5.c @@ -46,8 +46,12 @@ static int rc4_hmac_md5_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *iv, int enc) { EVP_RC4_HMAC_MD5 *key = data(ctx); + const int keylen = EVP_CIPHER_CTX_key_length(ctx); - RC4_set_key(&key->ks, EVP_CIPHER_CTX_key_length(ctx), inkey); + if (keylen <= 0) + return 0; + + RC4_set_key(&key->ks, keylen, inkey); MD5_Init(&key->head); /* handy when benchmarking */ key->tail = key->head; |