[ldns-users] Possible_memory_leak_in_ldns_key_new _frm_algorithm
Michael Sheldon
msheldon at godaddy.com
Wed Jun 6 22:11:13 UTC 2012
Been looking deeper, this may be an openssl thing. Certainly openssl
does not play nice with valgrind...
Michael Sheldon
Dev-DNS Services
GoDaddy.com
tel. (480)505-8800 x4372
mobile. (602)456-0255
> -------- Original Message --------
> Subject: [ldns-users] Possible_memory_leak_in_ldns_key_new
> _frm_algorithm
> From: "Michael Sheldon" <msheldon at godaddy.com>
> Date: Tue, June 05, 2012 3:41 pm
> To: ldns-users at open.nlnetlabs.nl
>
>
> So I've been chasing down a small memory leak when generating dnssec
> signing keys.
>
> valgrind backtrace was this:
>
> ==20296== 688 (136 direct, 552 indirect) bytes in 1 blocks are
> definitely lost in loss record 43 of 44
> ==20296== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
> ==20296== by 0x39E905D95D: CRYPTO_malloc (in
> /usr/lib64/libcrypto.so.1.0.0)
> ==20296== by 0x39E90A2A4E: DSA_new_method (in
> /usr/lib64/libcrypto.so.1.0.0)
> ==20296== by 0x39E90A3AB9: DSA_generate_parameters (in
> /usr/lib64/libcrypto.so.1.0.0)
> ==20296== by 0x39E2429AAA: ldns_key_new_frm_algorithm (keys.c:851)
>
> And similar for RSA.
>
> Through searching, I found that DSA_generate_parameters calls:
>
> 01002 ldns_key_set_dsa_key(ldns_key *k, DSA *d)
> 01003 {
> 01004 EVP_PKEY *key = EVP_PKEY_new();
> 01005 EVP_PKEY_set1_DSA(key, d);
> 01006 k->_key.key = key;
> 01007 }
>
> The documentation for EVP_PKEY_set1_DSA(EVP_PKEY *pkey,RSA *key), which
> is described as: set the key referenced by pkey to key.
>
> But also mentioned is EVP_PKEY_assign_RSA(EVP_PKEY *pkey,RSA *key),
> which has the description: also set the referenced key to key however
> these use the supplied key internally and so key will be freed when the
> parent pkey is freed.
>
> This implies that d is not freed when k->_key.key is freed, and d is not
> itself explicitly freed by either ldns_key_set_dsa_key or
> ldns_key_new_frm_algorithm which would account for the memory leak.
>
> The same applies for r when passed to ldns_key_set_rsa_key
>
>
>
> Or am I smoking something?
>
> Michael Sheldon
> Dev-DNS Services
> GoDaddy.com
>
>
>
> _______________________________________________
> ldns-users mailing list
> ldns-users at open.nlnetlabs.nl
> http://open.nlnetlabs.nl/mailman/listinfo/ldns-users
More information about the ldns-users
mailing list