Fix the allocation size in EVP_OpenInit and PEM_SignFinal
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Sun, 31 Mar 2019 10:00:16 +0000 (12:00 +0200)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Sat, 6 Apr 2019 08:20:10 +0000 (10:20 +0200)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8620)

(cherry picked from commit 8cf85d489978c384a3f193fb7cb25469e0559f27)

crypto/evp/p_open.c
crypto/pem/pem_sign.c

index f2976f8a994aef1334958e17c7701ba5d1fa82b9..7dcb95b2c38ea5185a1ac72a760b2642eb21f1ec 100644 (file)
@@ -40,7 +40,7 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
     }
 
     size = EVP_PKEY_size(priv);
-    key = OPENSSL_malloc(size + 2);
+    key = OPENSSL_malloc(size);
     if (key == NULL) {
         /* ERROR */
         EVPerr(EVP_F_EVP_OPENINIT, ERR_R_MALLOC_FAILURE);
index 9662eb14dbc9d54f927939b7eeed1d10e2d77d7a..06fce45e7c09fa1a6c29c6530e033f102992c874 100644 (file)
@@ -31,7 +31,7 @@ int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
     int i, ret = 0;
     unsigned int m_len;
 
-    m = OPENSSL_malloc(EVP_PKEY_size(pkey) + 2);
+    m = OPENSSL_malloc(EVP_PKEY_size(pkey));
     if (m == NULL) {
         PEMerr(PEM_F_PEM_SIGNFINAL, ERR_R_MALLOC_FAILURE);
         goto err;