From: Leonid Evdokimov Date: Wed, 19 Oct 2011 18:38:37 +0000 (+0400) Subject: Empty DNS reply with OK status is another way to say NODATA. X-Git-Tag: release-2.0.16-stable~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21a08d6869d53c81268ef131eb88cb1dd74a71f0;p=libevent Empty DNS reply with OK status is another way to say NODATA. Sometimes DNS reply has nothing but query section. It does not look like error, so it should be treated as NODATA with TTL=0 as soon as there is no SOA record to deduce negative TTL from. --- diff --git a/evdns.c b/evdns.c index 1550fe8f..7ad42b74 100644 --- a/evdns.c +++ b/evdns.c @@ -1044,7 +1044,7 @@ reply_parse(struct evdns_base *base, u8 *packet, int length) { */ TEST_NAME; j += 4; - if (j >= length) goto err; + if (j > length) goto err; } if (!name_matches) diff --git a/test/regress_dns.c b/test/regress_dns.c index 3eea4828..33cf9a97 100644 --- a/test/regress_dns.c +++ b/test/regress_dns.c @@ -497,6 +497,7 @@ static struct regress_dns_server_table search_table[] = { { "host2.c.example.com", "err", "3", 0 }, { "hostn.a.example.com", "errsoa", "0", 0 }, { "hostn.b.example.com", "errsoa", "3", 0 }, + { "hostn.c.example.com", "err", "0", 0 }, { "host", "err", "3", 0 }, { "host2", "err", "3", 0 }, @@ -513,7 +514,7 @@ dns_search_test(void *arg) ev_uint16_t portnum = 0; char buf[64]; - struct generic_dns_callback_result r[7]; + struct generic_dns_callback_result r[8]; tt_assert(regress_dnsserver(base, &portnum, search_table)); evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum); @@ -535,6 +536,7 @@ dns_search_test(void *arg) evdns_base_resolve_ipv4(dns, "host3", 0, generic_dns_callback, &r[4]); evdns_base_resolve_ipv4(dns, "hostn.a.example.com", DNS_NO_SEARCH, generic_dns_callback, &r[5]); evdns_base_resolve_ipv4(dns, "hostn.b.example.com", DNS_NO_SEARCH, generic_dns_callback, &r[6]); + evdns_base_resolve_ipv4(dns, "hostn.c.example.com", DNS_NO_SEARCH, generic_dns_callback, &r[7]); event_base_dispatch(base); @@ -551,6 +553,8 @@ dns_search_test(void *arg) tt_int_op(r[5].ttl, ==, 42); tt_int_op(r[6].result, ==, DNS_ERR_NOTEXIST); tt_int_op(r[6].ttl, ==, 42); + tt_int_op(r[7].result, ==, DNS_ERR_NODATA); + tt_int_op(r[7].ttl, ==, 0); end: if (dns)