mirror of
https://github.com/curl/curl.git
synced 2026-08-24 22:43:38 +03:00
urlapi: deny hostnames with more than one trailing dot
Or consisting of just a single dot. Such names cannot be resolved with DNS. While they *can* still be resolved with /etc/hosts or --resolve tricks, they easily cause internal problems because their trailing dots. Let's not allow them anymore. Closes #21622
This commit is contained in:
parent
88bb7f885f
commit
9135294115
3 changed files with 23 additions and 12 deletions
|
|
@ -475,6 +475,13 @@ static CURLUcode hostname_check(struct Curl_URL *u, char *hostname,
|
|||
if(hlen != len)
|
||||
/* hostname with bad content */
|
||||
return CURLUE_BAD_HOSTNAME;
|
||||
else if((hlen >= 2) &&
|
||||
(hostname[hlen - 1] == '.') && (hostname[hlen - 2] == '.'))
|
||||
/* more than one trailing dot is not allowed */
|
||||
return CURLUE_BAD_HOSTNAME;
|
||||
else if((hlen == 1) && (hostname[0] == '.'))
|
||||
/* just a single dot is not allowed */
|
||||
return CURLUE_BAD_HOSTNAME;
|
||||
}
|
||||
return CURLUE_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue