[openssl-commits] [openssl] master update

Matt Caswell matt at openssl.org
Wed Mar 30 23:20:43 UTC 2016


The branch master has been updated
       via  b3895f42a9a90a74097c75e39d87ed3212be18dd (commit)
      from  79c7f74d6cefd5d32fa20e69195ad3de834ce065 (commit)


- Log -----------------------------------------------------------------
commit b3895f42a9a90a74097c75e39d87ed3212be18dd
Author: Matt Caswell <matt at openssl.org>
Date:   Wed Mar 30 18:12:59 2016 +0100

    Remove the CRYPTO_mem_leaks adjustment for the BIO
    
    CRYPTO_mem_leaks attempts to adjust the count of bytes leaks to not
    include the BIO that is being used to print the results out. However this
    does not work properly. In all internal cases we switch off recording
    the memory allocation during creation of the BIO so it makes no difference.
    In other cases if the BIO allocates any additional memory during
    construction then the adjustment will be wrong anyway. It also skips over
    the BIO memory during print_leak anyway, so the BIO memory is never
    added into the total. In other words this was broken in lots of ways and
    has been since it was first added.
    
    The simplest solution is just to make it the documented behaviour that
    you must turn off memory logging when creating the BIO, and remove all
    the adjustment stuff completely. The adjustment code was only ever in
    master and never made it to a release branch so there is no loss of
    functionality.
    
    This commit also fixes a compilation failure when using
    enable-crypto-mdebug.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>

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

Summary of changes:
 crypto/mem_dbg.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c
index e69869d..d4d72f2 100644
--- a/crypto/mem_dbg.c
+++ b/crypto/mem_dbg.c
@@ -536,7 +536,6 @@ void CRYPTO_mem_debug_realloc(void *addr1, void *addr2, size_t num,
 typedef struct mem_leak_st {
     BIO *bio;
     int chunks;
-    int seen;
     long bytes;
 } MEM_LEAK;
 
@@ -560,12 +559,6 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
 
 #define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
 
-    /* Is one "leak" the BIO we were given? */
-    if (m->addr == (char *)l->bio) {
-        l->seen = 1;
-        return;
-    }
-
     lcl = localtime(&m->time);
     BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
                  lcl->tm_hour, lcl->tm_min, lcl->tm_sec);
@@ -653,14 +646,9 @@ int CRYPTO_mem_leaks(BIO *b)
     ml.bio = b;
     ml.bytes = 0;
     ml.chunks = 0;
-    ml.seen = 0;
     if (mh != NULL)
         lh_MEM_doall_MEM_LEAK(mh, print_leak, &ml);
-    /* Don't count the BIO that was passed in as a "leak" */
-    if (ml.seen && ml.chunks >= 1 && ml.bytes >= (int)sizeof (*b)) {
-        ml.chunks--;
-        ml.bytes -= (int)sizeof (*b);
-    }
+
     if (ml.chunks != 0) {
         BIO_printf(b, "%ld bytes leaked in %d chunks\n", ml.bytes, ml.chunks);
     } else {


More information about the openssl-commits mailing list