]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
pyLDNS: Fixed ldns_resolver's set_dnssec_anchors() and dnssec_anchors().
authorKarel Slany <karel.slany@nic.cz>
Tue, 27 Aug 2013 16:04:00 +0000 (18:04 +0200)
committerKarel Slany <karel.slany@nic.cz>
Tue, 27 Aug 2013 16:04:00 +0000 (18:04 +0200)
Added push- and pull-cloning to prevent memory corruption.

contrib/python/Changelog
contrib/python/ldns_packet.i
contrib/python/ldns_resolver.i

index 5747e668dfc1f30d241bd7c1fd62a7dc81d87a03..e3dcec51a611d21f5f8de2061aade7e932acac89 100644 (file)
@@ -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.
 
index aa69dac86af7a71dd7e77e735061a2f898d48d80..eeff4aa2359a35b1a189a7c195a529ca60af7144 100644 (file)
@@ -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 \
index 2b34d382ae023786b2579189177568df0b7d12ad..47f51220b3da7507efb00324154cffdb1066b459 100644 (file)
   }
 %}
 
+%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: