]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
* ldns_wire2pkt: fix null pointer dereference if pkt allocation fails
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 4 Apr 2017 14:36:50 +0000 (16:36 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 4 Apr 2017 14:36:50 +0000 (16:36 +0200)
  and fix memory leak with more EDNS sections
  Thanks Jan Vcelak

Changelog
wire2host.c

index 79f00aa15929eb00b782471200c2be98f132148e..fcf37cffdcec689cb7582f942e39ac5bdfda4844 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,9 @@
        * bugfix #1209: make install ldns.pc file
          Thanks Oleksandr Natalenko
        * removed duplicate condition in ldns_udp_send_query.
+       * ldns_wire2pkt: fix null pointer dereference if pkt allocation fails
+         and fix memory leak with more EDNS sections
+         Thanks Jan Vcelak
 
 1.7.0  2016-12-20
        * Fix lookup of relative names in ldns_resolver_search.
index 680d2f9dcb7082db1756f8b521d845ea44129030..a30e89e745913b667d5ae85f44a6f0461cc9ec8f 100644 (file)
@@ -412,6 +412,10 @@ ldns_wire2pkt(ldns_pkt **packet_p, const uint8_t *wire, size_t max)
 
        uint8_t data[4];
 
+       if (!packet) {
+               return LDNS_STATUS_MEM_ERR;
+       }
+
        status = ldns_wire2pkt_hdr(packet, wire, max, &pos);
        LDNS_STATUS_CHECK_GOTO(status, status_error);
 
@@ -464,6 +468,7 @@ ldns_wire2pkt(ldns_pkt **packet_p, const uint8_t *wire, size_t max)
                        ldns_pkt_set_edns_z(packet, ldns_read_uint16(&data[2]));
                        /* edns might not have rdfs */
                        if (ldns_rr_rdf(rr, 0)) {
+                               ldns_rdf_deep_free(ldns_pkt_edns_data(packet));
                                ldns_pkt_set_edns_data(packet, ldns_rdf_clone(ldns_rr_rdf(rr, 0)));
                        }
                        ldns_rr_free(rr);