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
This commit is contained in:
Richard Levitte 2003-12-01 13:25:37 +00:00
parent 1145e03870
commit 2fe9ab8e20

View File

@ -148,11 +148,18 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
#endif #endif
ctx->cipher=cipher; ctx->cipher=cipher;
ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size); if (ctx->cipher->ctx_size)
if (!ctx->cipher_data)
{ {
EVPerr(EVP_F_EVP_CIPHERINIT, ERR_R_MALLOC_FAILURE); ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
return 0; 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->key_len = cipher->key_len;
ctx->flags = 0; ctx->flags = 0;