Fix crash in drill(1) when IP has two subsequent dots

Cherry-pick crash fix from the upstream repo

PR:		226575
Reported by:	Goran Mekić <meka@tilda.center>
Obtained from:	https://git.nlnetlabs.nl/ldns/commit/?id=98291475
MFC after:	2 weeks
This commit is contained in:
Oleksandr Tymoshenko 2020-06-22 23:13:14 +00:00
parent 1a176e87df
commit e16b207739

View File

@ -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");