summaryrefslogtreecommitdiffstats
path: root/crypto/evp/e_des3.c
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2019-05-07 10:55:39 +1000
committerPauli <paul.dale@oracle.com>2019-05-08 09:52:58 +1000
commit6521cb0319e9bb1d49c93bd9885c7b253e90cef6 (patch)
tree0daa6eb02ad6f3e68cb6ade98584b8ea37097d2d /crypto/evp/e_des3.c
parent21d9856986e4b24a782e76270c8a83cc315faa3f (diff)
Coverity CID 1444956: Integer handling issues
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8888)
Diffstat (limited to 'crypto/evp/e_des3.c')
-rw-r--r--crypto/evp/e_des3.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c
index 6177659a83..52fde95fb0 100644
--- a/crypto/evp/e_des3.c
+++ b/crypto/evp/e_des3.c
@@ -280,15 +280,17 @@ static int des3_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
{
DES_cblock *deskey = ptr;
+ int kl;
switch (type) {
case EVP_CTRL_RAND_KEY:
- if (RAND_priv_bytes(ptr, EVP_CIPHER_CTX_key_length(ctx)) <= 0)
+ kl = EVP_CIPHER_CTX_key_length(ctx);
+ if (kl < 0 || RAND_priv_bytes(ptr, kl) <= 0)
return 0;
DES_set_odd_parity(deskey);
- if (EVP_CIPHER_CTX_key_length(ctx) >= 16)
+ if (kl >= 16)
DES_set_odd_parity(deskey + 1);
- if (EVP_CIPHER_CTX_key_length(ctx) >= 24)
+ if (kl >= 24)
DES_set_odd_parity(deskey + 2);
return 1;