[ldns-users] pyLDNS fixes in ldns_buffer, ldns_rdf, ldns_dname and others

Karel Slany karel.slany at nic.cz
Tue Jul 31 12:46:38 UTC 2012


Hello,

I've written three scripts testing the functionality of ldns_buffer,
ldns_rdf and ldns_dname Python classes. By running the scripts I've
encountered several problems which have been fixed in the attached
patch. The patch also contains the mentioned testing scripts, which need
to be added into the repository in order to prevent breaking the
functionality by code changes in future. So please don't forget to:

svn add trunk/contrib/python/examples/test_*.py
chmod +x trunk/contrib/python/examples/test_*.py

Description of the fixed issues follows.

Python 3 related:
* Fixed automatic conversion from string to ldns_rdf and ldns_dname.
Caused memory corruption when using Python 3. The #ifdef
SWIG_Python_str_AsChar does not actually work as SWIG_Python_str_AsChar
is a function (at least in SWIG 2.0.4), so it has been replaced. Also in
Python 3 the conversion would have caused memory leaks if it was working.
* In Python 3 the wrapper now raises TypeError instead of ValueError
when receiving a non FILE * argument when it should receive a FILE *
argument. In Python 2 it raises TypeError by default, so it was changed
to comply with Python 2.

Python serious issues:
* Fixed wrong handling of _ldns_rr_list_free() and
_ldns_rr_list_deep_free() when compiling with LDNS_DEBUG directive.
* Fixed malfunctioning ldns.ldns_rdf_new_frm_fp_l().
* Fixed malfunctioning ldns_drf.absolute() and ldns_dname.absolute()
* Marked several functions related to ldns_rdf and ldns_buffer as
returning new objects. It could lead to memory leaks, when not marked.
(ldns_rdf.address_reverse(), ldns_rdf.cat_clone(), etc.)
* And many small fixes preventing code crashes in ldns_buffer, ldns_rdf
and ldns_dname.

Interface fixes and additions:
* Method operating on ldns_dnames and returning dname ldns_rdfs now
return ldns_dname instances. (This represents no compatibility issues,
as ldns_dname is derived from ldns_rdf.)
* Improved documentation of ldns_buffer, ldns_rdf and ldns_dname classes.
* Methods ldns_buffer.available() and ldns_buffer.available_at() now
return bool types as described in the documentation.
* Added scripts for testing of basic functionality of the classes
ldns_buffer, ldns_rdf, ldns_dname.
* Added deprecation warnings to ldns_rdf methods operating on dname
rdfs. The user is encouraged to converts dname ldns_rdfs to ldns_dnames.
This saves several lines of sanity checking code in future.
* Extended ldns_dname constructor to accept ldns_rdfs containing dnames.

I've tested the changes using Python 2.7 and 3.2. The changes maintain
backward compatibility. However, in several cases the code will now
throw a deprecation warning about changes of the interface in future.

Best regards,
K.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ldns_buffer_rdf_dname.patch
Type: text/x-patch
Size: 156820 bytes
Desc: not available
URL: <http://lists.nlnetlabs.nl/pipermail/ldns-users/attachments/20120731/d249c1d8/attachment.bin>


More information about the ldns-users mailing list