From 82153e6e92117d092b1ea0630f2ba96ebb006fe7 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 10 Sep 2007 14:56:00 +0000 Subject: [PATCH] r15025@catbus: nickm | 2007-09-10 10:54:46 -0400 More DNS standard correctness changes: we preserve the CD flag,not the TC flag on responses. When we get a nonstandard query, we should say "NOTIMPL" rather than ignoring it. svn:r428 --- ChangeLog | 2 ++ evdns.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1f3fd2e0..a7d8a926 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,3 +9,5 @@ Changes in current version: o Fix a memory leak in the DNS server o Fix compilation when DNS_USE_OPENSSL_FOR_ID is enabled o Fix buffer size and string generation in evdns_resolve_reverse_ipv6(). + o Respond to nonstandard DNS queries with "NOTIMPL" rather than by ignoring them. + o In DNS responses, the CD flag should be preserved, not the TC flag. diff --git a/evdns.c b/evdns.c index 22f9a7a2..cb0c543f 100644 --- a/evdns.c +++ b/evdns.c @@ -949,8 +949,7 @@ request_parse(u8 *packet, int length, struct evdns_server_port *port, struct soc GET16(additional); if (flags & 0x8000) return -1; /* Must not be an answer. */ - if (flags & 0x7800) return -1; /* only standard queries are supported */ - flags &= 0x0300; /* Only TC and RD get preserved. */ + flags &= 0x0110; /* Only RD and CD get preserved. */ server_req = malloc(sizeof(struct server_request)); if (server_req == NULL) return -1; @@ -988,6 +987,13 @@ request_parse(u8 *packet, int length, struct evdns_server_port *port, struct soc server_req->port = port; port->refcnt++; + + /* Only standard queries are supported. */ + if (flags & 0x7800) { + evdns_server_request_respond(&(server_req->base), DNS_ERR_NOTIMPL); + return -1; + } + port->user_callback(&(server_req->base), port->user_data); return 0; -- 2.40.0