From: Karel Slany Date: Tue, 27 Aug 2013 16:04:00 +0000 (+0200) Subject: pyLDNS: Fixed ldns_resolver's set_dnssec_anchors() and dnssec_anchors(). X-Git-Tag: release-1.6.17rc1~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd685bbcac8a07dd0825bd66613fd637743deafc;p=thirdparty%2Fldns.git pyLDNS: Fixed ldns_resolver's set_dnssec_anchors() and dnssec_anchors(). Added push- and pull-cloning to prevent memory corruption. --- diff --git a/contrib/python/Changelog b/contrib/python/Changelog index 5747e668..e3dcec51 100644 --- a/contrib/python/Changelog +++ b/contrib/python/Changelog @@ -8,9 +8,11 @@ ldns_pkt.safe_push_rr_list(), ldns_pkt.set_additional(), ldns_pkt.set_answer(), ldns_pkt.set_answerfrom(), ldns_pkt.set_authority(), ldns_pkt.set_edns_data(), - ldns_pkt.set_question(), ldns_pkt.set_tsig(). + ldns_pkt.set_question(), ldns_pkt.set_tsig(), + ldns_resolver.set_dnssec_anchors(). * Added pull cloning for ldns_pkt.answerfrom(), ldns_pkt.edns_data(), - ldns_pkt.tsig(), ldns_resolver.axfr_last_pkt(). + ldns_pkt.tsig(), ldns_resolver.axfr_last_pkt(), + ldns_resolver.dnssec_anchors(). * Method ldns_rdf.reverse() now throws an exception when not applied on dname rdfs. This is to prevent assertion fails in ldns' C code. diff --git a/contrib/python/ldns_packet.i b/contrib/python/ldns_packet.i index aa69dac8..eeff4aa2 100644 --- a/contrib/python/ldns_packet.i +++ b/contrib/python/ldns_packet.i @@ -445,7 +445,7 @@ This simple example instances a resolver in order to resolve NS for nic.cz." .. note:: The type checking of parameter `rr_name` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. - This will probably change in future + This will probably change in future. """ if (not isinstance(rr_name, ldns_dname)) and \ isinstance(rr_name, ldns_rdf) and \ diff --git a/contrib/python/ldns_resolver.i b/contrib/python/ldns_resolver.i index 2b34d382..47f51220 100644 --- a/contrib/python/ldns_resolver.i +++ b/contrib/python/ldns_resolver.i @@ -80,10 +80,35 @@ } %} +%newobject _ldns_resolver_dnssec_anchors; +%rename(__ldns_resolver_dnssec_anchors) ldns_resolver_dnssec_anchors; +%inline +%{ + ldns_rr_list * _ldns_resolver_dnssec_anchors(const ldns_resolver *res) + { + return ldns_rr_list_clone(ldns_resolver_dnssec_anchors(res)); + } +%} + /* End of pull cloning. */ /* Clone data on push. */ +%rename(__ldns_resolver_set_dnssec_anchors) ldns_resolver_set_dnssec_anchors; +%inline +%{ + void _ldns_resolver_set_dnssec_anchors(ldns_resolver *res, + ldns_rr_list * rrl) + { + ldns_rr_list *rrl_clone = NULL; + if (rrl != NULL) { + rrl_clone = ldns_rr_list_clone(rrl); + } + /* May leak memory, when overwriting pointer value. */ + ldns_resolver_set_dnssec_anchors(res, rrl_clone); + } +%} + /* End of push cloning. */ @@ -393,37 +418,51 @@ record." #retvals: bool def dec_nameserver_count(self): - """Decrement the resolver's nameserver count. + """ + Decrement the resolver's name server count. """ _ldns.ldns_resolver_dec_nameserver_count(self) #parameters: ldns_resolver *, #retvals: def defnames(self): + """ + Does the resolver apply default domain name. + + :return: (bool) + """ return _ldns.ldns_resolver_defnames(self) #parameters: const ldns_resolver *, #retvals: bool def dnsrch(self): + """ + Does the resolver apply search list. + + :return: (bool) + """ return _ldns.ldns_resolver_dnsrch(self) #parameters: const ldns_resolver *, #retvals: bool def dnssec(self): - """Does the resolver do DNSSEC. + """ + Does the resolver do DNSSEC. - :return: (bool) true: yes, false: no + :return: (bool) True: yes, False: no. """ return _ldns.ldns_resolver_dnssec(self) #parameters: const ldns_resolver *, #retvals: bool def dnssec_anchors(self): - """Get the resolver's DNSSEC anchors. + """ + Get the resolver's DNSSEC anchors. - :return: (ldns_rr_list \*) an rr_list containg trusted DNSSEC anchors + :return: (:class:`ldns_rr_list`) An rr list containing trusted + DNSSEC anchors. """ - return _ldns.ldns_resolver_dnssec_anchors(self) + return _ldns._ldns_resolver_dnssec_anchors(self) #parameters: const ldns_resolver *, #retvals: ldns_rr_list * @@ -788,15 +827,16 @@ record." #parameters: ldns_resolver *,bool, #retvals: - def set_dnssec_anchors(self,l): - """Set the resolver's DNSSEC anchor list directly. - + def set_dnssec_anchors(self, l): + """ + Set the resolver's DNSSEC anchor list directly. RRs should be of type DS or DNSKEY. - :param l: - the list of RRs to use as trust anchors + :param l: The list of RRs to use as trust anchors. + :type l: :class:`ldns_rr_list` + :throws TypeError: When arguments of inappropriate types. """ - _ldns.ldns_resolver_set_dnssec_anchors(self,l) + _ldns._ldns_resolver_set_dnssec_anchors(self, l) #parameters: ldns_resolver *,ldns_rr_list *, #retvals: