Subject: Memory leaks

Memory leaks

From: Markus Doppelbauer <markus_at_gloria.tv>
Date: Wed, 01 Apr 2015 13:28:54 +0200

Hello,

First, thanks a lot for the new release. Maybe there are some
memory leaks:

a) #298: Clean openssl-tables via "EVP_cleanup()":
 https://www.openssl.org/docs/crypto/OpenSSL_add_all_algorithms.html

 Replace:

 #define libssh2_crypto_init() OpenSSL_add_all_algorithms()
 #define libssh2_crypto_exit()

 With:

 #define libssh2_crypto_init() OpenSSL_add_all_algorithms()
 #define libssh2_crypto_exit() EVP_cleanup();

b) #299: _libssh2_rsa_new() in openssl.c:69 is not free'd()
I have attached the valgrind-output.

Thanks a lot
Markus

==3020== Memcheck, a memory error detector
==3020== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==3020== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==3020== Command: bin/Debug/update
==3020==
==3020==
==3020== HEAP SUMMARY:
==3020== in use at exit: 416 bytes in 6 blocks
==3020== total heap usage: 5,825 allocs, 5,819 frees, 1,593,012 bytes allocated
==3020==
==3020== 24 bytes in 1 blocks are still reachable in loss record 1 of 6
==3020== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3020== by 0x80DED72: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E00E5: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E0A8A: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x8147926: RSA_new_method (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x5CADD56: _libssh2_rsa_new (openssl.c:69)
==3020== by 0x5C99785: hostkey_method_ssh_rsa_init (hostkey.c:95)
==3020== by 0x5C99E4E: diffie_hellman_sha1 (kex.c:267)
==3020== by 0x5C9B2A6: kex_method_diffie_hellman_group14_sha1_key_exchange (kex.c:799)
==3020== by 0x5C9BD89: _libssh2_kex_exchange (kex.c:1770)
==3020== by 0x5CA2756: libssh2_session_handshake (session.c:723)
==3020== by 0x912119: ssh2_connect(String const&, unsigned long, String const&, String const&, String const&) (ssh.cpp:1395)
==3020==
==3020== 24 bytes in 1 blocks are still reachable in loss record 2 of 6
==3020== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3020== by 0x80DED72: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x8164C7A: lh_insert (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E0113: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E0A8A: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x8147926: RSA_new_method (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x5CADD56: _libssh2_rsa_new (openssl.c:69)
==3020== by 0x5C99785: hostkey_method_ssh_rsa_init (hostkey.c:95)
==3020== by 0x5C99E4E: diffie_hellman_sha1 (kex.c:267)
==3020== by 0x5C9B2A6: kex_method_diffie_hellman_group14_sha1_key_exchange (kex.c:799)
==3020== by 0x5C9BD89: _libssh2_kex_exchange (kex.c:1770)
==3020== by 0x5CA2756: libssh2_session_handshake (session.c:723)
==3020==
==3020== 32 bytes in 1 blocks are still reachable in loss record 3 of 6
==3020== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3020== by 0x80DED72: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x816426E: sk_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E00FB: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E0A8A: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x8147926: RSA_new_method (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x5CADD56: _libssh2_rsa_new (openssl.c:69)
==3020== by 0x5C99785: hostkey_method_ssh_rsa_init (hostkey.c:95)
==3020== by 0x5C99E4E: diffie_hellman_sha1 (kex.c:267)
==3020== by 0x5C9B2A6: kex_method_diffie_hellman_group14_sha1_key_exchange (kex.c:799)
==3020== by 0x5C9BD89: _libssh2_kex_exchange (kex.c:1770)
==3020== by 0x5CA2756: libssh2_session_handshake (session.c:723)
==3020==
==3020== 32 bytes in 1 blocks are still reachable in loss record 4 of 6
==3020== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3020== by 0x80DED72: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x816428C: sk_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E00FB: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E0A8A: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x8147926: RSA_new_method (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x5CADD56: _libssh2_rsa_new (openssl.c:69)
==3020== by 0x5C99785: hostkey_method_ssh_rsa_init (hostkey.c:95)
==3020== by 0x5C99E4E: diffie_hellman_sha1 (kex.c:267)
==3020== by 0x5C9B2A6: kex_method_diffie_hellman_group14_sha1_key_exchange (kex.c:799)
==3020== by 0x5C9BD89: _libssh2_kex_exchange (kex.c:1770)
==3020== by 0x5CA2756: libssh2_session_handshake (session.c:723)
==3020==
==3020== 128 bytes in 1 blocks are still reachable in loss record 5 of 6
==3020== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3020== by 0x80DED72: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x8164961: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E0034: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E00C4: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E0A8A: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x8147926: RSA_new_method (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x5CADD56: _libssh2_rsa_new (openssl.c:69)
==3020== by 0x5C99785: hostkey_method_ssh_rsa_init (hostkey.c:95)
==3020== by 0x5C99E4E: diffie_hellman_sha1 (kex.c:267)
==3020== by 0x5C9B2A6: kex_method_diffie_hellman_group14_sha1_key_exchange (kex.c:799)
==3020== by 0x5C9BD89: _libssh2_kex_exchange (kex.c:1770)
==3020==
==3020== 176 bytes in 1 blocks are still reachable in loss record 6 of 6
==3020== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3020== by 0x80DED72: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x816493F: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E0034: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E00C4: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x80E0A8A: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x8147926: RSA_new_method (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==3020== by 0x5CADD56: _libssh2_rsa_new (openssl.c:69)
==3020== by 0x5C99785: hostkey_method_ssh_rsa_init (hostkey.c:95)
==3020== by 0x5C99E4E: diffie_hellman_sha1 (kex.c:267)
==3020== by 0x5C9B2A6: kex_method_diffie_hellman_group14_sha1_key_exchange (kex.c:799)
==3020== by 0x5C9BD89: _libssh2_kex_exchange (kex.c:1770)
==3020==
==3020== LEAK SUMMARY:
==3020== definitely lost: 0 bytes in 0 blocks
==3020== indirectly lost: 0 bytes in 0 blocks
==3020== possibly lost: 0 bytes in 0 blocks
==3020== still reachable: 416 bytes in 6 blocks
==3020== suppressed: 0 bytes in 0 blocks
==3020==
==3020== For counts of detected and suppressed errors, rerun with: -v
==3020== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2015-04-01