]> granicus.if.org Git - libevent/commitdiff
Empty DNS reply with OK status is another way to say NODATA.
authorLeonid Evdokimov <leon@darkk.net.ru>
Wed, 19 Oct 2011 18:38:37 +0000 (22:38 +0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 20 Oct 2011 02:15:35 +0000 (22:15 -0400)
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.

evdns.c
test/regress_dns.c

diff --git a/evdns.c b/evdns.c
index 1550fe8f163608f43125cc9b8bb44ae9f594b0e2..7ad42b74cf95d7d6416d25ed7432e5cee59c0d88 100644 (file)
--- 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)
index 3eea482817829d3eaaa0c03992fae715dca1e6dc..33cf9a9776bf627791d3ea2aa5c5936d4f26b818 100644 (file)
@@ -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)