It was pointed out to me that if the requested size is 0, we shouldn't
authorRichard Levitte <levitte@openssl.org>
Mon, 1 Dec 2003 13:25:39 +0000 (13:25 +0000)
committerRichard Levitte <levitte@openssl.org>
Mon, 1 Dec 2003 13:25:39 +0000 (13:25 +0000)
ty to allocate anything at all.  This will allow eNULL to still work.

PR: 751
Notified by: Lutz Jaenicke

crypto/evp/evp_enc.c

index e42e97284475deccf9a837923f4cfe212ed11afa..8ea5aa935dda7c1f03f1ed2bf12fea06bafc5c25 100644 (file)
@@ -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;