mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
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.
This commit is contained in:
parent
d58c15ee84
commit
21a08d6869
2
evdns.c
2
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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user