summaryrefslogtreecommitdiffstats
path: root/crypto/engine
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2019-05-07 10:52:52 +1000
committerPauli <paul.dale@oracle.com>2019-05-08 09:52:58 +1000
commit21d9856986e4b24a782e76270c8a83cc315faa3f (patch)
tree0d1eb489d8397b5b31e50a984991d41cc9188c03 /crypto/engine
parentd2c2e49eab69c7446c1c2c7227f63f8618ca99a5 (diff)
Coverity CID 1444957: Error handling issues
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8888)
Diffstat (limited to 'crypto/engine')
-rw-r--r--crypto/engine/eng_openssl.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c
index 5877a26d7a..d41006f864 100644
--- a/crypto/engine/eng_openssl.c
+++ b/crypto/engine/eng_openssl.c
@@ -189,12 +189,15 @@ typedef struct {
static int test_rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc)
{
+ const int n = EVP_CIPHER_CTX_key_length(ctx);
+
# ifdef TEST_ENG_OPENSSL_RC4_P_INIT
fprintf(stderr, "(TEST_ENG_OPENSSL_RC4) test_init_key() called\n");
# endif
- memcpy(&test(ctx)->key[0], key, EVP_CIPHER_CTX_key_length(ctx));
- RC4_set_key(&test(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx),
- test(ctx)->key);
+ if (n <= 0)
+ return n;
+ memcpy(&test(ctx)->key[0], key, n);
+ RC4_set_key(&test(ctx)->ks, n, test(ctx)->key);
return 1;
}