From ef32505633ad40bd3937edfa739f6b13ecdda599 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 3 Nov 2016 23:15:07 -0400 Subject: [PATCH] dns: set error to REFUSED when there are no answers --- modules/commands/os_dns.cpp | 1 - modules/m_dns.cpp | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp index 687f44f4a..b3062fa3d 100644 --- a/modules/commands/os_dns.cpp +++ b/modules/commands/os_dns.cpp @@ -940,7 +940,6 @@ class ModuleDNS : public Module if (packet->answers.size() == answer_size) { Log(this) << "Error! There are no servers with any IPs of type " << q.type; - /* Send back an empty answer anyway */ } } } diff --git a/modules/m_dns.cpp b/modules/m_dns.cpp index 93f09246e..4dc6d7bfa 100644 --- a/modules/m_dns.cpp +++ b/modules/m_dns.cpp @@ -854,6 +854,9 @@ class MyManager : public Manager, public Timer } } + if (packet->answers.empty() && packet->authorities.empty() && packet->additional.empty() && packet->error == ERROR_NONE) + packet->error = ERROR_REFUSED; // usually safe, won't cause an NXDOMAIN to get cached + s->Reply(packet); return true; }