[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Sat Jan 2 19:39:49 UTC 2016


The branch master has been updated
       via  6aa0ba4bb2833b1e0d6ae98c54c79bfed8257c3a (commit)
      from  4fa52141b08fca89250805afcf2f112a2e0d3500 (commit)


- Log -----------------------------------------------------------------
commit 6aa0ba4bb2833b1e0d6ae98c54c79bfed8257c3a
Author: Richard Levitte <levitte at openssl.org>
Date:   Fri Dec 18 13:03:45 2015 +0100

    Fix a possible memleak
    
    If there's a failure allocating md_data, the destination pctx will have
    a shared pointer with the source EVP_MD_CTX, which will lead to problems
    when either the source or the destination is freed.
    
    Reviewed-by: Stephen Henson <steve at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 crypto/evp/digest.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c
index 5da0e01..33688f9 100644
--- a/crypto/evp/digest.c
+++ b/crypto/evp/digest.c
@@ -312,6 +312,13 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
     EVP_MD_CTX_reset(out);
     memcpy(out, in, sizeof(*out));
 
+    /* Null these variables, since they are getting fixed up
+     * properly below.  Anything else may cause a memleak and/or
+     * double free if any of the memory allocations below fail
+     */
+    out->md_data = NULL;
+    out->pctx = NULL;
+
     if (in->md_data && out->digest->ctx_size) {
         if (tmp_buf)
             out->md_data = tmp_buf;


More information about the openssl-commits mailing list