diff options
author | Pauli <ppzgs1@gmail.com> | 2021-03-19 14:49:57 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-04-08 08:49:27 +1000 |
commit | 1002bb9ff0e35b4195586199222f9bad77837162 (patch) | |
tree | 1364ffee9693474dde4fbdc3b5b3d7a260ac69ce | |
parent | 89f7ea045be346ecd9085804a429bb4842843344 (diff) |
evp: fix coverity 1472682: 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_cast.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/evp/e_cast.c b/crypto/evp/e_cast.c index 8325a5f8d2..883030224b 100644 --- a/crypto/evp/e_cast.c +++ b/crypto/evp/e_cast.c @@ -40,7 +40,11 @@ IMPLEMENT_BLOCK_CIPHER(cast5, ks, CAST, EVP_CAST_KEY, static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { - CAST_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), key); + int keylen = EVP_CIPHER_CTX_key_length(ctx); + + if (keylen <= 0) + return 0; + CAST_set_key(&data(ctx)->ks, keylen, key); return 1; } |