mirror of
https://github.com/curl/curl.git
synced 2026-08-25 07:33:36 +03:00
hsts: ignore numberical IP address hosts
Also, use a single function library-wide for detecting if a given hostname is a numerical IP address. Reported-by: Harry Sintonen Fixes #7146 Closes #7149
This commit is contained in:
parent
9097843e8f
commit
1c1d9f1aff
6 changed files with 32 additions and 40 deletions
19
lib/hostip.c
19
lib/hostip.c
|
|
@ -460,6 +460,25 @@ Curl_cache_addr(struct Curl_easy *data,
|
|||
return dns;
|
||||
}
|
||||
|
||||
/*
|
||||
* Curl_host_is_ipnum() returns TRUE if the given string is a numerical IPv4
|
||||
* (or IPv6 if supported) address.
|
||||
*/
|
||||
bool Curl_host_is_ipnum(const char *hostname)
|
||||
{
|
||||
struct in_addr in;
|
||||
#ifdef ENABLE_IPV6
|
||||
struct in6_addr in6;
|
||||
#endif
|
||||
if(Curl_inet_pton(AF_INET, hostname, &in) > 0
|
||||
#ifdef ENABLE_IPV6
|
||||
|| Curl_inet_pton(AF_INET6, hostname, &in6) > 0
|
||||
#endif
|
||||
)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Curl_resolv() is the main name resolve function within libcurl. It resolves
|
||||
* a name and returns a pointer to the entry in the 'entry' argument (if one
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue