mirror of
https://github.com/yrutschle/sslh.git
synced 2025-04-18 17:57:39 +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;
|
struct addrinfo hint;
|
||||||
char *end;
|
char *end;
|
||||||
int res;
|
int res;
|
||||||
char* host;
|
char* host, *host_base;
|
||||||
|
|
||||||
memset(&hint, 0, sizeof(hint));
|
memset(&hint, 0, sizeof(hint));
|
||||||
hint.ai_family = PF_UNSPEC;
|
hint.ai_family = PF_UNSPEC;
|
||||||
hint.ai_socktype = SOCK_STREAM;
|
hint.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
/* Copy parameter so not to clobber data in libconfig */
|
/* 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) {
|
if (res == -1) {
|
||||||
log_message(LOG_ERR, "asprintf: cannot allocate memory");
|
log_message(LOG_ERR, "asprintf: cannot allocate memory");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
host = host_base;
|
||||||
|
|
||||||
/* If it is a RFC-Compliant IPv6 address ("[1234::12]:443"), remove brackets
|
/* If it is a RFC-Compliant IPv6 address ("[1234::12]:443"), remove brackets
|
||||||
* around IP address */
|
* around IP address */
|
||||||
if (host[0] == '[') {
|
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);
|
res = getaddrinfo(host, serv, &hint, out);
|
||||||
if (res)
|
if (res)
|
||||||
log_message(LOG_ERR, "%s `%s:%s'\n", gai_strerror(res), host, serv);
|
log_message(LOG_ERR, "%s `%s:%s'\n", gai_strerror(res), host, serv);
|
||||||
free(host);
|
free(host_base);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user