[ldns-users] Issue with ldns_resolver_deep_free and TSIG

Michael Sheldon msheldon at godaddy.com
Fri Apr 16 17:46:54 UTC 2010


Another bit of a surprise...

Normally, when pushing objects to a container, like an rr to an rrlist,
the _push function pushes the pointer to the object, which means that it
will later be cleaned up with a deep_free

However, when pushing a nameserver rdf to a resolver, it clones it, thus
requiring that the original rdf object be separately free'd. This is
inconsistent with most other ldns container objects like rr_list, zone,
etc.

I guess generally I expect simple "primitives" being _set to be cloned
(strings, etc) but objects passed to  _push to be pushed as pointers.



Michael Sheldon

-------- Original Message --------
Subject: Re: [ldns-users] Issue with ldns_resolver_deep_free and TSIG
From: "W.C.A. Wijngaards" <wouter at NLnetLabs.nl>
Date: Fri, April 16, 2010 5:48 am
To: ldns-users at open.nlnetlabs.nl

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Michael,

Yes this is wrong. I guess the least-surprising solution is to copy the
strings and delete them, for all three values.

Best regards,
 Wouter


On 04/15/2010 07:01 PM, Michael Sheldon wrote:
> When assigning TSIG parameters to ldns_resolver using
> ldns_resolver_tsig_keyname, ldns_resolver_tsig_algorithm and
> ldns_resolver_tsig_keydata, those functions merely set the pointer to
> the pointer value passed, they do not actually copy the data. However,
> when ldns_resolver_deep_free is called, it attempts to free
> res->_tsig_keyname.
> 
> First, ldns_resolver_deep_free probably should not attempt to free
> these, unless the set functions are modified to make copies instead of
> just storing the pointer.
> 
> Second, and possibly more significant, ldns_resolver_deep_free is
> inconsistent in that it only attempts to free one of the three values,
> but not the others. For someone who *does* expect the values to be
> freed, this would result in a memory leak.
> 
> Michael Sheldon
> 
> 
> 
> _______________________________________________
> ldns-users mailing list
> ldns-users at open.nlnetlabs.nl
> http://open.nlnetlabs.nl/mailman/listinfo/ldns-users

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkvIXJEACgkQkDLqNwOhpPi6RQCfSMYr9kS8Gkwr9XX04YVKh2Wy
BvQAn0tLknzXNsy43oihyLs69/Gd1mGx
=wdWJ
-----END PGP SIGNATURE-----
_______________________________________________
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