summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem Toorop <willem@nlnetlabs.nl>2019-01-17 11:39:06 +0100
committerWillem Toorop <willem@nlnetlabs.nl>2019-01-17 11:39:06 +0100
commit9829147582f66ab78b2035c1485c16cebe897477 (patch)
tree66d86c7cc257f90d7991d8db029f96df66e4d5ef
parentd69d8e87f4df550e993377f10419b0dcc210634d (diff)
downloadldns-9829147582f66ab78b2035c1485c16cebe897477.tar.gz
Fix #4221 drill -x crashes with malformed IPv4
Thanks Oleksandr Tymoshenko
-rw-r--r--Changelog2
-rw-r--r--drill/drill.c18
2 files changed, 12 insertions, 8 deletions
diff --git a/Changelog b/Changelog
index 7b229712..68231448 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,6 @@
1.7.1 ????-??-??
+ * bugfix #4221: drill -x crashes with malformed IPv4 address
+ Tahnks Oleksandr Tymoshenko
* bugfix #3437: CDS & CDNSKEY RRsets should be signed with the KSK
Thanks Tony Finch
* bugfix #1566, #1568, #1569, #1570: Potential NULL Dereferences
diff --git a/drill/drill.c b/drill/drill.c
index 3a9482b3..d66ee862 100644
--- a/drill/drill.c
+++ b/drill/drill.c
@@ -787,15 +787,17 @@ main(int argc, char *argv[])
qname = ldns_dname_new_frm_str(ip6_arpa_str);
} else {
qname = ldns_dname_new_frm_str(name);
- qname_tmp = ldns_dname_reverse(qname);
- ldns_rdf_deep_free(qname);
- qname = qname_tmp;
- qname_tmp = ldns_dname_new_frm_str("in-addr.arpa.");
- status = ldns_dname_cat(qname, qname_tmp);
- if (status != LDNS_STATUS_OK) {
- error("%s", "could not create reverse address for ip4: %s\n", ldns_get_errorstr_by_id(status));
+ if (qname) {
+ qname_tmp = ldns_dname_reverse(qname);
+ ldns_rdf_deep_free(qname);
+ qname = qname_tmp;
+ qname_tmp = ldns_dname_new_frm_str("in-addr.arpa.");
+ status = ldns_dname_cat(qname, qname_tmp);
+ if (status != LDNS_STATUS_OK) {
+ error("%s", "could not create reverse address for ip4: %s\n", ldns_get_errorstr_by_id(status));
+ }
+ ldns_rdf_deep_free(qname_tmp);
}
- ldns_rdf_deep_free(qname_tmp);
}
if (!qname) {
error("%s", "-x implies an ip address");