mirror of
https://github.com/curl/curl.git
synced 2026-08-04 11:26:14 +03:00
hostcheck: fail wildcard match if host starts with a dot
A hostname cannot start with a dot when DNS is used, but there are other ways. Amend unit test 1397 Closes #19869
This commit is contained in:
parent
121c540168
commit
2535c4298f
2 changed files with 4 additions and 2 deletions
|
|
@ -92,8 +92,8 @@ static bool hostmatch(const char *hostname,
|
|||
if(strncmp(pattern, "*.", 2))
|
||||
return pmatch(hostname, hostlen, pattern, patternlen);
|
||||
|
||||
/* detect IP address as hostname and fail the match if so */
|
||||
else if(Curl_host_is_ipnum(hostname))
|
||||
/* detect host as IP address or starting with a dot and fail if so */
|
||||
else if(Curl_host_is_ipnum(hostname) || (hostname[0] == '.'))
|
||||
return FALSE;
|
||||
|
||||
/* We require at least 2 dots in the pattern to avoid too wide wildcard
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ static CURLcode test_unit1397(const char *arg)
|
|||
};
|
||||
|
||||
static const struct testcase tests[] = {
|
||||
{".hello.com", "*.hello.com", FALSE },
|
||||
{"a.hello.com", "*.hello.com", TRUE },
|
||||
{ "", "", FALSE },
|
||||
{ "a", "", FALSE },
|
||||
{ "", "b", FALSE },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue