mirror of
https://github.com/curl/curl.git
synced 2026-08-24 21:13:40 +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
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include "hostcheck.h"
|
||||
#include "strcase.h"
|
||||
#include "inet_pton.h"
|
||||
#include "hostip.h"
|
||||
|
||||
#include "curl_memory.h"
|
||||
/* The last #include file should be: */
|
||||
|
|
@ -67,10 +67,6 @@ static int hostmatch(char *hostname, char *pattern)
|
|||
const char *pattern_label_end, *pattern_wildcard, *hostname_label_end;
|
||||
int wildcard_enabled;
|
||||
size_t prefixlen, suffixlen;
|
||||
struct in_addr ignored;
|
||||
#ifdef ENABLE_IPV6
|
||||
struct sockaddr_in6 si6;
|
||||
#endif
|
||||
|
||||
/* normalize pattern and hostname by stripping off trailing dots */
|
||||
size_t len = strlen(hostname);
|
||||
|
|
@ -86,12 +82,8 @@ static int hostmatch(char *hostname, char *pattern)
|
|||
CURL_HOST_MATCH : CURL_HOST_NOMATCH;
|
||||
|
||||
/* detect IP address as hostname and fail the match if so */
|
||||
if(Curl_inet_pton(AF_INET, hostname, &ignored) > 0)
|
||||
if(Curl_host_is_ipnum(hostname))
|
||||
return CURL_HOST_NOMATCH;
|
||||
#ifdef ENABLE_IPV6
|
||||
if(Curl_inet_pton(AF_INET6, hostname, &si6.sin6_addr) > 0)
|
||||
return CURL_HOST_NOMATCH;
|
||||
#endif
|
||||
|
||||
/* We require at least 2 dots in pattern to avoid too wide wildcard
|
||||
match. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue