]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
evp: fix coverity 1451510: argument cannot be negative
authorPauli <ppzgs1@gmail.com>
Fri, 19 Mar 2021 04:50:11 +0000 (14:50 +1000)
committerPauli <pauli@openssl.org>
Wed, 7 Apr 2021 22:49:27 +0000 (08:49 +1000)
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14620)

crypto/evp/e_rc4.c

index 10b83aea6d5821d35d4b8bd83b4c8aa45e0c1f8a..94107c72c34751383a86bc8df69bfc622e4d92ef 100644 (file)
@@ -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;
 }