|
|
7b35e2 |
From c5fcd8ab8ee1b66d0ef75b02f72ccfc3ebf50cf5 Mon Sep 17 00:00:00 2001
|
|
|
7b35e2 |
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
|
|
|
7b35e2 |
Date: Wed, 12 Sep 2018 15:01:37 +0200
|
|
|
7b35e2 |
Subject: [PATCH 1/2] Purge unused variables
|
|
|
7b35e2 |
|
|
|
7b35e2 |
---
|
|
|
7b35e2 |
packaging/ldns-config.in | 3 ---
|
|
|
7b35e2 |
1 file changed, 3 deletions(-)
|
|
|
7b35e2 |
|
|
|
7b35e2 |
diff --git a/packaging/ldns-config.in b/packaging/ldns-config.in
|
|
|
7b35e2 |
index 950c135..a8c860e 100755
|
|
|
7b35e2 |
--- a/packaging/ldns-config.in
|
|
|
7b35e2 |
+++ b/packaging/ldns-config.in
|
|
|
7b35e2 |
@@ -1,9 +1,6 @@
|
|
|
7b35e2 |
#!/bin/sh
|
|
|
7b35e2 |
|
|
|
7b35e2 |
-prefix="@prefix@"
|
|
|
7b35e2 |
-exec_prefix="@exec_prefix@"
|
|
|
7b35e2 |
VERSION="@PACKAGE_VERSION@"
|
|
|
7b35e2 |
-CPPFLAGS="@CPPFLAGS@ @LIBSSL_CPPFLAGS@ @PYTHON_CPPFLAGS@"
|
|
|
7b35e2 |
LIBS="@LIBS@ @LIBSSL_LIBS@"
|
|
|
7b35e2 |
INCLUDEDIR="@includedir@"
|
|
|
7b35e2 |
LIBVERSION="@VERSION_INFO@"
|
|
|
7b35e2 |
--
|
|
|
7b35e2 |
2.20.1
|
|
|
7b35e2 |
|
|
|
7b35e2 |
|
|
|
7b35e2 |
From db06eb482b09a0bcdaf3f688702b1c0df2cb1eca Mon Sep 17 00:00:00 2001
|
|
|
7b35e2 |
From: Willem Toorop <willem@nlnetlabs.nl>
|
|
|
7b35e2 |
Date: Thu, 11 Jul 2019 15:22:44 +0200
|
|
|
7b35e2 |
Subject: [PATCH 2/2] Issues detected in ldns library by scan of Coverity
|
|
|
7b35e2 |
MIME-Version: 1.0
|
|
|
7b35e2 |
Content-Type: text/plain; charset=UTF-8
|
|
|
7b35e2 |
Content-Transfer-Encoding: 8bit
|
|
|
7b35e2 |
|
|
|
7b35e2 |
Thanks Petr Menšík
|
|
|
7b35e2 |
---
|
|
|
7b35e2 |
dnssec.c | 6 +++++-
|
|
|
7b35e2 |
dnssec_sign.c | 4 ++--
|
|
|
7b35e2 |
dnssec_verify.c | 18 ++++++------------
|
|
|
7b35e2 |
dnssec_zone.c | 23 +++++++++++++++++------
|
|
|
7b35e2 |
host2str.c | 13 +++++++------
|
|
|
7b35e2 |
host2wire.c | 22 ++++++++++++++++------
|
|
|
7b35e2 |
net.c | 12 ++++++++++--
|
|
|
7b35e2 |
packet.c | 2 ++
|
|
|
7b35e2 |
radix.c | 5 ++++-
|
|
|
7b35e2 |
str2host.c | 2 ++
|
|
|
7b35e2 |
10 files changed, 71 insertions(+), 36 deletions(-)
|
|
|
7b35e2 |
|
|
|
7b35e2 |
diff --git a/dnssec.c b/dnssec.c
|
|
|
7b35e2 |
index e3c99de..b2dd3f3 100644
|
|
|
7b35e2 |
--- a/dnssec.c
|
|
|
7b35e2 |
+++ b/dnssec.c
|
|
|
7b35e2 |
@@ -149,6 +149,7 @@ ldns_dnssec_nsec3_closest_encloser(const ldns_rdf *qname,
|
|
|
7b35e2 |
LDNS_FREE(salt);
|
|
|
7b35e2 |
ldns_rdf_deep_free(zone_name);
|
|
|
7b35e2 |
ldns_rdf_deep_free(sname);
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(hashed_sname);
|
|
|
7b35e2 |
return NULL;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
|
|
|
7b35e2 |
@@ -1556,6 +1557,7 @@ ldns_pkt_verify_time(const ldns_pkt *p, ldns_rr_type t, const ldns_rdf *o,
|
|
|
7b35e2 |
ldns_rr_list *sigs_covered;
|
|
|
7b35e2 |
ldns_rdf *rdf_t;
|
|
|
7b35e2 |
ldns_rr_type t_netorder;
|
|
|
7b35e2 |
+ ldns_status status;
|
|
|
7b35e2 |
|
|
|
7b35e2 |
if (!k) {
|
|
|
7b35e2 |
return LDNS_STATUS_ERR;
|
|
|
7b35e2 |
@@ -1607,7 +1609,9 @@ ldns_pkt_verify_time(const ldns_pkt *p, ldns_rr_type t, const ldns_rdf *o,
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
return LDNS_STATUS_ERR;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
- return ldns_verify_time(rrset, sigs, k, check_time, good_keys);
|
|
|
7b35e2 |
+ status = ldns_verify_time(rrset, sigs, k, check_time, good_keys);
|
|
|
7b35e2 |
+ ldns_rr_list_deep_free(rrset);
|
|
|
7b35e2 |
+ return status;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
|
|
|
7b35e2 |
ldns_status
|
|
|
7b35e2 |
diff --git a/dnssec_sign.c b/dnssec_sign.c
|
|
|
7b35e2 |
index 22f0981..94ea925 100644
|
|
|
7b35e2 |
--- a/dnssec_sign.c
|
|
|
7b35e2 |
+++ b/dnssec_sign.c
|
|
|
7b35e2 |
@@ -234,8 +234,6 @@ ldns_sign_public(ldns_rr_list *rrset, ldns_key_list *keys)
|
|
|
7b35e2 |
|
|
|
7b35e2 |
new_owner = NULL;
|
|
|
7b35e2 |
|
|
|
7b35e2 |
- signatures = ldns_rr_list_new();
|
|
|
7b35e2 |
-
|
|
|
7b35e2 |
/* prepare a signature and add all the know data
|
|
|
7b35e2 |
* prepare the rrset. Sign this together. */
|
|
|
7b35e2 |
rrset_clone = ldns_rr_list_clone(rrset);
|
|
|
7b35e2 |
@@ -252,6 +250,8 @@ ldns_sign_public(ldns_rr_list *rrset, ldns_key_list *keys)
|
|
|
7b35e2 |
/* sort */
|
|
|
7b35e2 |
ldns_rr_list_sort(rrset_clone);
|
|
|
7b35e2 |
|
|
|
7b35e2 |
+ signatures = ldns_rr_list_new();
|
|
|
7b35e2 |
+
|
|
|
7b35e2 |
for (key_count = 0;
|
|
|
7b35e2 |
key_count < ldns_key_list_key_count(keys);
|
|
|
7b35e2 |
key_count++) {
|
|
|
7b35e2 |
diff --git a/dnssec_verify.c b/dnssec_verify.c
|
|
|
7b35e2 |
index c554e4f..c7e2fba 100644
|
|
|
7b35e2 |
--- a/dnssec_verify.c
|
|
|
7b35e2 |
+++ b/dnssec_verify.c
|
|
|
7b35e2 |
@@ -1583,8 +1583,6 @@ ldns_dnssec_verify_denial_nsec3_match( ldns_rr *rr
|
|
|
7b35e2 |
bool wildcard_covered = false;
|
|
|
7b35e2 |
ldns_rdf *zone_name;
|
|
|
7b35e2 |
ldns_rdf *hashed_name;
|
|
|
7b35e2 |
- /* self assignment to suppress uninitialized warning */
|
|
|
7b35e2 |
- ldns_rdf *next_closer = next_closer;
|
|
|
7b35e2 |
ldns_rdf *hashed_next_closer;
|
|
|
7b35e2 |
size_t i;
|
|
|
7b35e2 |
ldns_status result = LDNS_STATUS_DNSSEC_NSEC_RR_NOT_COVERED;
|
|
|
7b35e2 |
@@ -1659,6 +1657,7 @@ ldns_dnssec_verify_denial_nsec3_match( ldns_rr *rr
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(hashed_name);
|
|
|
7b35e2 |
result = LDNS_STATUS_DNSSEC_NSEC_RR_NOT_COVERED;
|
|
|
7b35e2 |
/* wildcard no data? section 8.7 */
|
|
|
7b35e2 |
closest_encloser = ldns_dnssec_nsec3_closest_encloser(
|
|
|
7b35e2 |
@@ -1748,7 +1747,9 @@ ldns_dnssec_verify_denial_nsec3_match( ldns_rr *rr
|
|
|
7b35e2 |
/* Query name *is* the "next closer". */
|
|
|
7b35e2 |
hashed_next_closer = hashed_name;
|
|
|
7b35e2 |
} else {
|
|
|
7b35e2 |
-
|
|
|
7b35e2 |
+ ldns_rdf *next_closer;
|
|
|
7b35e2 |
+
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(hashed_name);
|
|
|
7b35e2 |
/* "next closer" has less labels than the query name.
|
|
|
7b35e2 |
* Create the name and hash it.
|
|
|
7b35e2 |
*/
|
|
|
7b35e2 |
@@ -1762,6 +1763,7 @@ ldns_dnssec_verify_denial_nsec3_match( ldns_rr *rr
|
|
|
7b35e2 |
next_closer
|
|
|
7b35e2 |
);
|
|
|
7b35e2 |
(void) ldns_dname_cat(hashed_next_closer, zone_name);
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(next_closer);
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
/* Find the NSEC3 that covers the "next closer" */
|
|
|
7b35e2 |
for (i = 0; i < ldns_rr_list_rr_count(nsecs); i++) {
|
|
|
7b35e2 |
@@ -1776,15 +1778,7 @@ ldns_dnssec_verify_denial_nsec3_match( ldns_rr *rr
|
|
|
7b35e2 |
break;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
- if (ldns_dname_label_count(closest_encloser) + 1
|
|
|
7b35e2 |
- < ldns_dname_label_count(ldns_rr_owner(rr))) {
|
|
|
7b35e2 |
-
|
|
|
7b35e2 |
- /* "next closer" has less labels than the query name.
|
|
|
7b35e2 |
- * Dispose of the temporary variables that held that name.
|
|
|
7b35e2 |
- */
|
|
|
7b35e2 |
- ldns_rdf_deep_free(hashed_next_closer);
|
|
|
7b35e2 |
- ldns_rdf_deep_free(next_closer);
|
|
|
7b35e2 |
- }
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(hashed_next_closer);
|
|
|
7b35e2 |
ldns_rdf_deep_free(closest_encloser);
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
|
|
|
7b35e2 |
diff --git a/dnssec_zone.c b/dnssec_zone.c
|
|
|
7b35e2 |
index f610a3c..e089754 100644
|
|
|
7b35e2 |
--- a/dnssec_zone.c
|
|
|
7b35e2 |
+++ b/dnssec_zone.c
|
|
|
7b35e2 |
@@ -746,6 +746,7 @@ ldns_dnssec_zone_new_frm_fp_l(ldns_dnssec_zone** z, FILE* fp, const ldns_rdf* or
|
|
|
7b35e2 |
newzone = NULL;
|
|
|
7b35e2 |
} else {
|
|
|
7b35e2 |
ldns_dnssec_zone_free(newzone);
|
|
|
7b35e2 |
+ newzone = NULL;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
|
|
|
7b35e2 |
error:
|
|
|
7b35e2 |
@@ -1105,8 +1106,12 @@ ldns_dnssec_zone_add_empty_nonterminals_nsec3(
|
|
|
7b35e2 |
ldns_rdf *ent_name;
|
|
|
7b35e2 |
|
|
|
7b35e2 |
if (!(ent_name = ldns_dname_clone_from(
|
|
|
7b35e2 |
- next_name, i)))
|
|
|
7b35e2 |
+ next_name, i))) {
|
|
|
7b35e2 |
+
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(l1);
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(l2);
|
|
|
7b35e2 |
return LDNS_STATUS_MEM_ERR;
|
|
|
7b35e2 |
+ }
|
|
|
7b35e2 |
|
|
|
7b35e2 |
if (nsec3s && zone->_nsec3params) {
|
|
|
7b35e2 |
ldns_rdf *ent_hashed_name;
|
|
|
7b35e2 |
@@ -1114,28 +1119,34 @@ ldns_dnssec_zone_add_empty_nonterminals_nsec3(
|
|
|
7b35e2 |
if (!(ent_hashed_name =
|
|
|
7b35e2 |
ldns_nsec3_hash_name_frm_nsec3(
|
|
|
7b35e2 |
zone->_nsec3params,
|
|
|
7b35e2 |
- ent_name)))
|
|
|
7b35e2 |
+ ent_name))) {
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(l1);
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(l2);
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(ent_name);
|
|
|
7b35e2 |
return LDNS_STATUS_MEM_ERR;
|
|
|
7b35e2 |
+ }
|
|
|
7b35e2 |
node = ldns_rbtree_search(nsec3s,
|
|
|
7b35e2 |
ent_hashed_name);
|
|
|
7b35e2 |
if (!node) {
|
|
|
7b35e2 |
ldns_rdf_deep_free(l1);
|
|
|
7b35e2 |
ldns_rdf_deep_free(l2);
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(ent_name);
|
|
|
7b35e2 |
continue;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
new_name = ldns_dnssec_name_new();
|
|
|
7b35e2 |
if (!new_name) {
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(l1);
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(l2);
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(ent_name);
|
|
|
7b35e2 |
return LDNS_STATUS_MEM_ERR;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
new_name->name = ent_name;
|
|
|
7b35e2 |
- if (!new_name->name) {
|
|
|
7b35e2 |
- ldns_dnssec_name_free(new_name);
|
|
|
7b35e2 |
- return LDNS_STATUS_MEM_ERR;
|
|
|
7b35e2 |
- }
|
|
|
7b35e2 |
new_name->name_alloced = true;
|
|
|
7b35e2 |
new_node = LDNS_MALLOC(ldns_rbnode_t);
|
|
|
7b35e2 |
if (!new_node) {
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(l1);
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(l2);
|
|
|
7b35e2 |
ldns_dnssec_name_free(new_name);
|
|
|
7b35e2 |
return LDNS_STATUS_MEM_ERR;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
diff --git a/host2str.c b/host2str.c
|
|
|
7b35e2 |
index 747d543..f39a184 100644
|
|
|
7b35e2 |
--- a/host2str.c
|
|
|
7b35e2 |
+++ b/host2str.c
|
|
|
7b35e2 |
@@ -1085,12 +1085,12 @@ ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf)
|
|
|
7b35e2 |
/* no gateway */
|
|
|
7b35e2 |
break;
|
|
|
7b35e2 |
case 1:
|
|
|
7b35e2 |
- gateway_data = LDNS_XMALLOC(uint8_t, LDNS_IP4ADDRLEN);
|
|
|
7b35e2 |
- if(!gateway_data)
|
|
|
7b35e2 |
- return LDNS_STATUS_MEM_ERR;
|
|
|
7b35e2 |
if (ldns_rdf_size(rdf) < offset + LDNS_IP4ADDRLEN) {
|
|
|
7b35e2 |
return LDNS_STATUS_ERR;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
+ gateway_data = LDNS_XMALLOC(uint8_t, LDNS_IP4ADDRLEN);
|
|
|
7b35e2 |
+ if(!gateway_data)
|
|
|
7b35e2 |
+ return LDNS_STATUS_MEM_ERR;
|
|
|
7b35e2 |
memcpy(gateway_data, &data[offset], LDNS_IP4ADDRLEN);
|
|
|
7b35e2 |
gateway = ldns_rdf_new(LDNS_RDF_TYPE_A,
|
|
|
7b35e2 |
LDNS_IP4ADDRLEN , gateway_data);
|
|
|
7b35e2 |
@@ -1101,12 +1101,12 @@ ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf)
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
break;
|
|
|
7b35e2 |
case 2:
|
|
|
7b35e2 |
- gateway_data = LDNS_XMALLOC(uint8_t, LDNS_IP6ADDRLEN);
|
|
|
7b35e2 |
- if(!gateway_data)
|
|
|
7b35e2 |
- return LDNS_STATUS_MEM_ERR;
|
|
|
7b35e2 |
if (ldns_rdf_size(rdf) < offset + LDNS_IP6ADDRLEN) {
|
|
|
7b35e2 |
return LDNS_STATUS_ERR;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
+ gateway_data = LDNS_XMALLOC(uint8_t, LDNS_IP6ADDRLEN);
|
|
|
7b35e2 |
+ if(!gateway_data)
|
|
|
7b35e2 |
+ return LDNS_STATUS_MEM_ERR;
|
|
|
7b35e2 |
memcpy(gateway_data, &data[offset], LDNS_IP6ADDRLEN);
|
|
|
7b35e2 |
offset += LDNS_IP6ADDRLEN;
|
|
|
7b35e2 |
gateway =
|
|
|
7b35e2 |
@@ -1129,6 +1129,7 @@ ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf)
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
|
|
|
7b35e2 |
if (ldns_rdf_size(rdf) <= offset) {
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(gateway);
|
|
|
7b35e2 |
return LDNS_STATUS_ERR;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
public_key_size = ldns_rdf_size(rdf) - offset;
|
|
|
7b35e2 |
diff --git a/host2wire.c b/host2wire.c
|
|
|
7b35e2 |
index 4d8aa30..a12b6b0 100644
|
|
|
7b35e2 |
--- a/host2wire.c
|
|
|
7b35e2 |
+++ b/host2wire.c
|
|
|
7b35e2 |
@@ -67,17 +67,27 @@ ldns_dname2buffer_wire_compress(ldns_buffer *buffer, const ldns_rdf *name, ldns_
|
|
|
7b35e2 |
{
|
|
|
7b35e2 |
/* Not found. Write cache entry, take off first label, write it, */
|
|
|
7b35e2 |
/* try again with the rest of the name. */
|
|
|
7b35e2 |
- node = LDNS_MALLOC(ldns_rbnode_t);
|
|
|
7b35e2 |
- if(!node)
|
|
|
7b35e2 |
- {
|
|
|
7b35e2 |
- return LDNS_STATUS_MEM_ERR;
|
|
|
7b35e2 |
- }
|
|
|
7b35e2 |
if (ldns_buffer_position(buffer) < 16384) {
|
|
|
7b35e2 |
- node->key = ldns_rdf_clone(name);
|
|
|
7b35e2 |
+ ldns_rdf *key;
|
|
|
7b35e2 |
+
|
|
|
7b35e2 |
+ node = LDNS_MALLOC(ldns_rbnode_t);
|
|
|
7b35e2 |
+ if(!node)
|
|
|
7b35e2 |
+ {
|
|
|
7b35e2 |
+ return LDNS_STATUS_MEM_ERR;
|
|
|
7b35e2 |
+ }
|
|
|
7b35e2 |
+
|
|
|
7b35e2 |
+ key = ldns_rdf_clone(name);
|
|
|
7b35e2 |
+ if (!key) {
|
|
|
7b35e2 |
+ LDNS_FREE(node);
|
|
|
7b35e2 |
+ return LDNS_STATUS_MEM_ERR;
|
|
|
7b35e2 |
+ }
|
|
|
7b35e2 |
+ node->key = key;
|
|
|
7b35e2 |
node->data = (void *) (intptr_t) ldns_buffer_position(buffer);
|
|
|
7b35e2 |
if(!ldns_rbtree_insert(compression_data,node))
|
|
|
7b35e2 |
{
|
|
|
7b35e2 |
/* fprintf(stderr,"Name not found but now it's there?\n"); */
|
|
|
7b35e2 |
+ ldns_rdf_deep_free(key);
|
|
|
7b35e2 |
+ LDNS_FREE(node);
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
label = ldns_dname_label(name, 0);
|
|
|
7b35e2 |
diff --git a/net.c b/net.c
|
|
|
7b35e2 |
index 9e048d2..6e6a12b 100644
|
|
|
7b35e2 |
--- a/net.c
|
|
|
7b35e2 |
+++ b/net.c
|
|
|
7b35e2 |
@@ -202,6 +202,7 @@ ldns_tcp_connect_from(const struct sockaddr_storage *to, socklen_t tolen,
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
#endif
|
|
|
7b35e2 |
if (from && bind(sockfd, (const struct sockaddr*)from, fromlen) == SOCK_INVALID){
|
|
|
7b35e2 |
+ close_socket(sockfd);
|
|
|
7b35e2 |
return 0;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
|
|
|
7b35e2 |
@@ -337,7 +338,7 @@ ldns_tcp_send_from(uint8_t **result, ldns_buffer *qbin,
|
|
|
7b35e2 |
answer = ldns_tcp_read_wire_timeout(sockfd, answer_size, timeout);
|
|
|
7b35e2 |
close_socket(sockfd);
|
|
|
7b35e2 |
|
|
|
7b35e2 |
- if (*answer_size == 0) {
|
|
|
7b35e2 |
+ if (!answer) {
|
|
|
7b35e2 |
/* oops */
|
|
|
7b35e2 |
return LDNS_STATUS_NETWORK_ERR;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
@@ -390,6 +391,7 @@ ldns_udp_bgsend_from(ldns_buffer *qbin,
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
|
|
|
7b35e2 |
if (from && bind(sockfd, (const struct sockaddr*)from, fromlen) == -1){
|
|
|
7b35e2 |
+ close_socket(sockfd);
|
|
|
7b35e2 |
return 0;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
|
|
|
7b35e2 |
@@ -437,7 +439,7 @@ ldns_udp_send_from(uint8_t **result, ldns_buffer *qbin,
|
|
|
7b35e2 |
answer = ldns_udp_read_wire(sockfd, answer_size, NULL, NULL);
|
|
|
7b35e2 |
close_socket(sockfd);
|
|
|
7b35e2 |
|
|
|
7b35e2 |
- if (*answer_size == 0) {
|
|
|
7b35e2 |
+ if (!answer) {
|
|
|
7b35e2 |
/* oops */
|
|
|
7b35e2 |
return LDNS_STATUS_NETWORK_ERR;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
@@ -571,6 +573,9 @@ ldns_send_buffer(ldns_pkt **result, ldns_resolver *r, ldns_buffer *qb, ldns_rdf
|
|
|
7b35e2 |
if (!reply_bytes) {
|
|
|
7b35e2 |
/* the current nameserver seems to have a problem, blacklist it */
|
|
|
7b35e2 |
if (ldns_resolver_fail(r)) {
|
|
|
7b35e2 |
+ if(src) {
|
|
|
7b35e2 |
+ LDNS_FREE(src);
|
|
|
7b35e2 |
+ }
|
|
|
7b35e2 |
LDNS_FREE(ns);
|
|
|
7b35e2 |
return LDNS_STATUS_ERR;
|
|
|
7b35e2 |
} else {
|
|
|
7b35e2 |
@@ -918,6 +923,9 @@ ldns_axfr_start(ldns_resolver *resolver, const ldns_rdf *domain, ldns_rr_class c
|
|
|
7b35e2 |
src, (socklen_t)src_len,
|
|
|
7b35e2 |
ldns_resolver_timeout(resolver));
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
+ if (src) {
|
|
|
7b35e2 |
+ LDNS_FREE(src);
|
|
|
7b35e2 |
+ }
|
|
|
7b35e2 |
|
|
|
7b35e2 |
if (resolver->_socket == SOCK_INVALID) {
|
|
|
7b35e2 |
ldns_pkt_free(query);
|
|
|
7b35e2 |
diff --git a/packet.c b/packet.c
|
|
|
7b35e2 |
index 95f8f3f..f8fb960 100644
|
|
|
7b35e2 |
--- a/packet.c
|
|
|
7b35e2 |
+++ b/packet.c
|
|
|
7b35e2 |
@@ -928,11 +928,13 @@ ldns_pkt_query_new_frm_str_internal(ldns_pkt **p, const char *name,
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
|
|
|
7b35e2 |
if (!ldns_pkt_set_flags(packet, flags)) {
|
|
|
7b35e2 |
+ ldns_pkt_free(packet);
|
|
|
7b35e2 |
return LDNS_STATUS_ERR;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
|
|
|
7b35e2 |
question_rr = ldns_rr_new();
|
|
|
7b35e2 |
if (!question_rr) {
|
|
|
7b35e2 |
+ ldns_pkt_free(packet);
|
|
|
7b35e2 |
return LDNS_STATUS_MEM_ERR;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
|
|
|
7b35e2 |
diff --git a/radix.c b/radix.c
|
|
|
7b35e2 |
index 43f7365..9695e13 100644
|
|
|
7b35e2 |
--- a/radix.c
|
|
|
7b35e2 |
+++ b/radix.c
|
|
|
7b35e2 |
@@ -225,9 +225,9 @@ ldns_radix_insert(ldns_radix_t* tree, uint8_t* key, radix_strlen_t len,
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
} else if (pos == len) {
|
|
|
7b35e2 |
/** Exact match found */
|
|
|
7b35e2 |
+ LDNS_FREE(add);
|
|
|
7b35e2 |
if (prefix->data) {
|
|
|
7b35e2 |
/* Element already exists */
|
|
|
7b35e2 |
- LDNS_FREE(add);
|
|
|
7b35e2 |
return LDNS_STATUS_EXISTS_ERR;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
prefix->data = data;
|
|
|
7b35e2 |
@@ -1120,12 +1120,15 @@ ldns_radix_array_split(ldns_radix_array_t* array, uint8_t* key,
|
|
|
7b35e2 |
if (array->len - common_len > 1) {
|
|
|
7b35e2 |
if (!ldns_radix_prefix_remainder(common_len+1,
|
|
|
7b35e2 |
array->str, array->len, &s1, &l1)) {
|
|
|
7b35e2 |
+ LDNS_FREE(common);
|
|
|
7b35e2 |
return 0;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
if (strlen_to_add - common_len > 1) {
|
|
|
7b35e2 |
if (!ldns_radix_prefix_remainder(common_len+1,
|
|
|
7b35e2 |
str_to_add, strlen_to_add, &s2, &l2)) {
|
|
|
7b35e2 |
+ LDNS_FREE(common);
|
|
|
7b35e2 |
+ LDNS_FREE(s1);
|
|
|
7b35e2 |
return 0;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
diff --git a/str2host.c b/str2host.c
|
|
|
7b35e2 |
index c3afba1..68bccf1 100644
|
|
|
7b35e2 |
--- a/str2host.c
|
|
|
7b35e2 |
+++ b/str2host.c
|
|
|
7b35e2 |
@@ -445,6 +445,7 @@ ldns_str2rdf_str(ldns_rdf **rd, const char *str)
|
|
|
7b35e2 |
*++dp = ch;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
if (! str) {
|
|
|
7b35e2 |
+ LDNS_FREE(data);
|
|
|
7b35e2 |
return LDNS_STATUS_SYNTAX_BAD_ESCAPE;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
length = (size_t)(dp - data);
|
|
|
7b35e2 |
@@ -1494,6 +1495,7 @@ ldns_str2rdf_long_str(ldns_rdf **rd, const char *str)
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
if (! str) {
|
|
|
7b35e2 |
+ LDNS_FREE(data);
|
|
|
7b35e2 |
return LDNS_STATUS_SYNTAX_BAD_ESCAPE;
|
|
|
7b35e2 |
}
|
|
|
7b35e2 |
if (!(length = (size_t)(dp - data))) {
|
|
|
7b35e2 |
--
|
|
|
7b35e2 |
2.20.1
|
|
|
7b35e2 |
|