mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-20 02:38:32 +00:00
Fix regression in --rebind-domain-ok in 2.86
The 2.86 domain-match rewrite changed matching from whole-labels to substring matching, so example.com would match example.com and www.example.com, as before, but also goodexample.com, which is a regression. This restores the original behaviour. Also restore the behaviour of --rebind-domain-ok=// to match domains with onlt a single label and no dots. Thanks to Sung Pae for reporting these bugs and supplying an initial patch.
This commit is contained in:
@@ -153,11 +153,20 @@ static int domain_no_rebind(char *domain)
|
|||||||
{
|
{
|
||||||
struct rebind_domain *rbd;
|
struct rebind_domain *rbd;
|
||||||
size_t tlen, dlen = strlen(domain);
|
size_t tlen, dlen = strlen(domain);
|
||||||
|
char *dots = strchr(domain, '.');
|
||||||
|
|
||||||
|
/* Match whole labels only. Empty domain matches no dots (any single label) */
|
||||||
for (rbd = daemon->no_rebind; rbd; rbd = rbd->next)
|
for (rbd = daemon->no_rebind; rbd; rbd = rbd->next)
|
||||||
if (dlen >= (tlen = strlen(rbd->domain)) && strcmp(rbd->domain, &domain[dlen - tlen]) == 0)
|
{
|
||||||
|
if (dlen >= (tlen = strlen(rbd->domain)) &&
|
||||||
|
hostname_isequal(rbd->domain, &domain[dlen - tlen]) &&
|
||||||
|
(dlen == tlen || domain[dlen - tlen - 1] == '.'))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (tlen == 0 && !dots)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user