summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2003-12-01 13:25:37 +0000
committerRichard Levitte <levitte@openssl.org>2003-12-01 13:25:37 +0000
commit2fe9ab8e20e1480825cd5962ca516924f4f03f5e (patch)
tree65e6c00b2c8254084ec8b5298c19ea01e5809827
parent1145e03870dd82eae00bb45e0b2162494b9b2f38 (diff)
It was pointed out to me that if the requested size is 0, we shouldn't
ty to allocate anything at all. This will allow eNULL to still work. PR: 751 Notified by: Lutz Jaenicke
-rw-r--r--crypto/evp/evp_enc.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index 658391105c..cecb09cbe7 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -148,11 +148,18 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
#endif
ctx->cipher=cipher;
- ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
- if (!ctx->cipher_data)
+ if (ctx->cipher->ctx_size)
{
- EVPerr(EVP_F_EVP_CIPHERINIT, ERR_R_MALLOC_FAILURE);
- return 0;
+ ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
+ if (!ctx->cipher_data)
+ {
+ EVPerr(EVP_F_EVP_CIPHERINIT, ERR_R_MALLOC_FAILURE);
+ return 0;
+ }
+ }
+ else
+ {
+ ctx->cipher_data = NULL;
}
ctx->key_len = cipher->key_len;
ctx->flags = 0;