I'm getting some memory leaks when I use OpenSSL.  I was not able to get rid 
of these leaks, even when I use EVP_cleanup() and ERR_free_strings() at the 
end of my program.


Memory Leak 1.  PEM_read_PrivateKey()
=====================================

    EVP_PKEY* key = PEM_read_PrivateKey(fp, NULL, 0, NULL);
        ...
    EVP_PKEY_free(key);

    Valgrind reports:

    ==27769== 24 bytes in 1 blocks are still reachable in loss record 2 of 
20
    ==27769==    at 0x4A05809: malloc (vg_replace_malloc.c:149)
    ==27769==    by 0x3C3C6DAD41: CRYPTO_malloc (in 
/lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3C65B565: (within /lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3C65B98A: (within /lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3C66F9B3: RSA_new_method (in 
/lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3C66F33C: (within /lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3C692EA4: (within /lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3C696004: ASN1_item_ex_d2i (in 
/lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3C6960F3: ASN1_item_d2i (in 
/lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3C68FC0C: d2i_PrivateKey (in 
/lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3C6A10B9: PEM_read_bio_PrivateKey (in 
/lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3C6A1300: PEM_read_PrivateKey (in 
/lib64/libcrypto.so.0.9.8e)


Memory Leak 2. SSL_library_init()
=================================

    Valgrind reports:

    ==27769== 24 bytes in 1 blocks are still reachable in loss record 6 of 
20
    ==27769==    at 0x4A05809: malloc (vg_replace_malloc.c:149)
    ==27769==    by 0x3C3C6DAD41: CRYPTO_malloc (in 
/lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3C65B565: (within /lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3C65BB3B: (within /lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3C6BFBFA: COMP_zlib (in /lib64/libcrypto.so.0.9.8e)
    ==27769==    by 0x3C3CA31D7F: (within /lib64/libssl.so.0.9.8e)
    ==27769==    by 0x3C3CA31F48: SSL_COMP_get_compression_methods (in 
/lib64/libssl.so.0.9.8e)
    ==27769==    by 0x3C3CA37784: SSL_library_init (in 
/lib64/libssl.so.0.9.8e)


Memory Leak 3. HMAC_Init()
==========================

    HMAC_CTX hm;

    HMAC_Init(&hm, ...);
    HMAC_Update(&hm, ...);
    HMAC_Final(&hm, ...);
        ...
    HMAC_cleanup(&hm);


    Valgrind reports:

    ==31996==    at 0x4A05809: malloc (vg_replace_malloc.c:149)
    ==31996==    by 0x3C3C6DAD41: CRYPTO_malloc (in 
/lib64/libcrypto.so.0.9.8e)
    ==31996==    by 0x3C3C6D8A1D: EVP_DigestInit_ex (in 
/lib64/libcrypto.so.0.9.8e)
    ==31996==    by 0x3C3C6EB36B: HMAC_Init_ex (in 
/lib64/libcrypto.so.0.9.8e)




______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to