aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/librdns
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/librdns')
-rw-r--r--contrib/librdns/curve.c1
-rw-r--r--contrib/librdns/packet.c7
-rw-r--r--contrib/librdns/parse.c8
-rw-r--r--contrib/librdns/resolver.c10
-rw-r--r--contrib/librdns/util.c3
5 files changed, 19 insertions, 10 deletions
diff --git a/contrib/librdns/curve.c b/contrib/librdns/curve.c
index c6479c31e..19ec2508c 100644
--- a/contrib/librdns/curve.c
+++ b/contrib/librdns/curve.c
@@ -715,6 +715,7 @@ rdns_curve_send (struct rdns_request *req, void *plugin_data,
boxed_len = req->pos + crypto_box_ZEROBYTES;
m = malloc (boxed_len);
if (m == NULL) {
+ free(creq);
return -1;
}
diff --git a/contrib/librdns/packet.c b/contrib/librdns/packet.c
index 99536668c..5c822ffef 100644
--- a/contrib/librdns/packet.c
+++ b/contrib/librdns/packet.c
@@ -92,7 +92,7 @@ rdns_format_dns_name (struct rdns_resolver *resolver, const char *in,
char *o;
int labels = 0;
size_t label_len, olen, remain;
- uint32_t *uclabel;
+ uint32_t *uclabel = NULL;
size_t punylabel_len, uclabel_len;
char tmp_label[DNS_D_MAXLABEL];
bool need_encode = false;
@@ -163,6 +163,7 @@ rdns_format_dns_name (struct rdns_resolver *resolver, const char *in,
}
free (uclabel);
+ uclabel = NULL;
if (dot) {
p = dot + 1;
@@ -230,9 +231,11 @@ rdns_format_dns_name (struct rdns_resolver *resolver, const char *in,
return true;
- err:
+err:
free (*out);
*out = NULL;
+ free (uclabel);
+
return false;
}
diff --git a/contrib/librdns/parse.c b/contrib/librdns/parse.c
index 18bb6a694..1a9c01838 100644
--- a/contrib/librdns/parse.c
+++ b/contrib/librdns/parse.c
@@ -351,6 +351,10 @@ rdns_parse_rr (struct rdns_resolver *resolver,
case DNS_T_TXT:
case DNS_T_SPF:
if (datalen <= *remain) {
+ if (datalen > UINT16_MAX / 2) {
+ rdns_info ("too large datalen; domain %s", rep->requested_name);
+ return -1;
+ }
elt->content.txt.data = malloc(datalen + 1);
if (elt->content.txt.data == NULL) {
rdns_err ("failed to allocate %d bytes for TXT record; domain %s",
@@ -413,6 +417,10 @@ rdns_parse_rr (struct rdns_resolver *resolver,
rdns_info ("stripped dns reply while reading TLSA record; domain %s", rep->requested_name);
return -1;
}
+ if (datalen > UINT16_MAX / 2) {
+ rdns_info ("too large datalen; domain %s", rep->requested_name);
+ return -1;
+ }
GET8 (elt->content.tlsa.usage);
GET8 (elt->content.tlsa.selector);
GET8 (elt->content.tlsa.match_type);
diff --git a/contrib/librdns/resolver.c b/contrib/librdns/resolver.c
index 6e3792f7e..2c402077c 100644
--- a/contrib/librdns/resolver.c
+++ b/contrib/librdns/resolver.c
@@ -150,13 +150,7 @@ rdns_make_reply (struct rdns_request *req, enum dns_rcode rcode)
rep->code = rcode;
req->reply = rep;
rep->authenticated = false;
-
- if (req) {
- rep->requested_name = req->requested_names[0].name;
- }
- else {
- rep->requested_name = NULL;
- }
+ rep->requested_name = req->requested_names[0].name;
}
return rep;
@@ -1133,4 +1127,6 @@ void rdns_resolver_set_fake_reply (struct rdns_resolver *resolver,
HASH_ADD (hh, resolver->fake_elts, key, sizeof (*srch) + len, fake_rep);
}
+
+ free (srch);
}
diff --git a/contrib/librdns/util.c b/contrib/librdns/util.c
index 920e94b99..be31c8f14 100644
--- a/contrib/librdns/util.c
+++ b/contrib/librdns/util.c
@@ -207,7 +207,7 @@ rdns_make_client_socket (const char *credits,
hints.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;
snprintf (portbuf, sizeof (portbuf), "%d", (int)port);
- if ((r = getaddrinfo (credits, portbuf, &hints, &res)) == 0) {
+ if (getaddrinfo (credits, portbuf, &hints, &res) == 0) {
r = rdns_make_inet_socket (type, res, psockaddr, psocklen);
if (r != -1 && psockaddr) {
@@ -217,6 +217,7 @@ rdns_make_client_socket (const char *credits,
if (cpy == NULL) {
close (r);
+ freeaddrinfo (res);
return -1;
}