Fix problems with upper-case in domain-match.

The domain-match rewrite didn't take into account
that domain names are case-insensitive, so things like

--address=/Example.com/.....

didn't work correctly.
This commit is contained in:
Simon Kelley
2021-11-28 18:39:42 +00:00
parent 9560658c5b
commit e3093b532c
4 changed files with 15 additions and 6 deletions

View File

@@ -367,7 +367,7 @@ int sa_len(union mysockaddr *addr)
}
/* don't use strcasecmp and friends here - they may be messed up by LOCALE */
int hostname_isequal(const char *a, const char *b)
int hostname_order(const char *a, const char *b)
{
unsigned int c1, c2;
@@ -380,11 +380,19 @@ int hostname_isequal(const char *a, const char *b)
if (c2 >= 'A' && c2 <= 'Z')
c2 += 'a' - 'A';
if (c1 != c2)
return 0;
if (c1 < c2)
return -1;
else if (c1 > c2)
return 1;
} while (c1);
return 1;
return 0;
}
int hostname_isequal(const char *a, const char *b)
{
return hostname_order(a, b) == 0;
}
/* is b equal to or a subdomain of a return 2 for equal, 1 for subdomain */