mirror of
https://github.com/yrutschle/sslh.git
synced 2025-04-14 08:07:14 +03:00
fix IPv6 parse error introduced in 7bf3e12c30d0585743792982ed8bcfc44aecae34
This commit is contained in:
parent
83be63d282
commit
1a6ba5edc0
8
common.c
8
common.c
@ -456,19 +456,21 @@ int resolve_split_name(struct addrinfo **out, const char* ct_host, const char* s
|
||||
struct addrinfo hint;
|
||||
char *end;
|
||||
int res;
|
||||
char* host;
|
||||
char* host, *host_base;
|
||||
|
||||
memset(&hint, 0, sizeof(hint));
|
||||
hint.ai_family = PF_UNSPEC;
|
||||
hint.ai_socktype = SOCK_STREAM;
|
||||
|
||||
/* Copy parameter so not to clobber data in libconfig */
|
||||
res = asprintf(&host, "%s", ct_host);
|
||||
res = asprintf(&host_base, "%s", ct_host);
|
||||
if (res == -1) {
|
||||
log_message(LOG_ERR, "asprintf: cannot allocate memory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
host = host_base;
|
||||
|
||||
/* If it is a RFC-Compliant IPv6 address ("[1234::12]:443"), remove brackets
|
||||
* around IP address */
|
||||
if (host[0] == '[') {
|
||||
@ -483,7 +485,7 @@ int resolve_split_name(struct addrinfo **out, const char* ct_host, const char* s
|
||||
res = getaddrinfo(host, serv, &hint, out);
|
||||
if (res)
|
||||
log_message(LOG_ERR, "%s `%s:%s'\n", gai_strerror(res), host, serv);
|
||||
free(host);
|
||||
free(host_base);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user