summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKinichiro Inoguchi <inoguchi@cvs.openbsd.org>2022-01-20 11:31:38 +0000
committerKinichiro Inoguchi <inoguchi@cvs.openbsd.org>2022-01-20 11:31:38 +0000
commit06c23695279e7b3bcdd9cb82deb3bf9ab6592bbb (patch)
tree3fe29d662a8e33d2017239f105916d6f3b816e7c
parent792400ee4b44f86e9f7079f9dea473bf2c557ae3 (diff)
Add check for EVP_CIPHER_CTX_ctrl
suggestion from tb@
-rw-r--r--lib/libcrypto/evp/e_rc2.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libcrypto/evp/e_rc2.c b/lib/libcrypto/evp/e_rc2.c
index d8c331d535f..b07fafddfd3 100644
--- a/lib/libcrypto/evp/e_rc2.c
+++ b/lib/libcrypto/evp/e_rc2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: e_rc2.c,v 1.13 2022/01/20 11:22:48 inoguchi Exp $ */
+/* $OpenBSD: e_rc2.c,v 1.14 2022/01/20 11:31:37 inoguchi Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -150,7 +150,8 @@ rc2_meth_to_magic(EVP_CIPHER_CTX *e)
{
int i;
- EVP_CIPHER_CTX_ctrl(e, EVP_CTRL_GET_RC2_KEY_BITS, 0, &i);
+ if (EVP_CIPHER_CTX_ctrl(e, EVP_CTRL_GET_RC2_KEY_BITS, 0, &i) <= 0)
+ return (0);
if (i == 128)
return (RC2_128_MAGIC);
else if (i == 64)
@@ -199,8 +200,9 @@ rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
return (-1);
if (i > 0 && !EVP_CipherInit_ex(c, NULL, NULL, NULL, iv, -1))
return -1;
- EVP_CIPHER_CTX_ctrl(c, EVP_CTRL_SET_RC2_KEY_BITS,
- key_bits, NULL);
+ if (EVP_CIPHER_CTX_ctrl(c, EVP_CTRL_SET_RC2_KEY_BITS,
+ key_bits, NULL) <= 0)
+ return -1;
if (!EVP_CIPHER_CTX_set_key_length(c, key_bits / 8))
return -1;
}