Fix logical error in d0ae3f5a4d

The code which checked for a possible local answer to a domain,
like --address=/example.com/1.2.3.4 could return false positives,
causing upstream NXDOMAIN replies to be rewritten as NOERROR.

Thanks to Dominik DL6ER for the bug report and analysis.
This commit is contained in:
Simon Kelley
2021-07-05 20:56:11 +01:00
parent 8acdc3ede7
commit df25f204ba

View File

@@ -289,10 +289,17 @@ int filter_servers(int seed, int flags, int *lowout, int *highout)
#define SERV_LOCAL_ADDRESS (SERV_6ADDR | SERV_4ADDR | SERV_ALL_ZEROS) #define SERV_LOCAL_ADDRESS (SERV_6ADDR | SERV_4ADDR | SERV_ALL_ZEROS)
for (i = nlow; (flags & F_CONFIG) && i < nhigh && (daemon->serverarray[i]->flags & SERV_LOCAL_ADDRESS); i++); if (flags & F_CONFIG)
{
/* We're just lookin for any matches that return an RR. */
for (i = nlow; i < nhigh; i++)
if (daemon->serverarray[i]->flags & SERV_LOCAL_ADDRESS)
break;
if (i != nlow) /* failed, return failure. */
nhigh = i; if (i == nhigh)
nhigh = nlow;
}
else else
{ {
for (i = nlow; i < nhigh && (daemon->serverarray[i]->flags & SERV_6ADDR); i++); for (i = nlow; i < nhigh && (daemon->serverarray[i]->flags & SERV_6ADDR); i++);