Fix possible SEGV when no servers defined.

If there exists a --address=/<domain>/  or --server=/<domain>/#
configuration but no upstream server config unqualified by
domain then when a query which doesnt match the domain is
recieved it will use the qualfied server config and in the process
possibly make an out-of-bounds memory access.

Thanks to Daniel Danzberger for spotting the bug.
This commit is contained in:
Simon Kelley
2023-03-06 23:00:58 +00:00
parent 997982f78b
commit f5ef0f064c
2 changed files with 14 additions and 2 deletions

View File

@@ -253,9 +253,10 @@ int lookup_domain(char *domain, int flags, int *lowout, int *highout)
if (highout)
*highout = nhigh;
if (nlow == nhigh)
/* qlen == -1 when we failed to match even an empty query, if there are no default servers. */
if (nlow == nhigh || qlen == -1)
return 0;
return 1;
}