mirror of
https://github.com/yrutschle/sslh.git
synced 2025-04-18 17:57:39 +03:00
check name resolution error to avoid segfault
This commit is contained in:
parent
6f949419d1
commit
940461de18
@ -225,13 +225,16 @@ static void mark_active(struct connection* cnx)
|
|||||||
/* Creates a new non-blocking socket */
|
/* Creates a new non-blocking socket */
|
||||||
static int nonblocking_socket(struct sslhcfg_protocols_item* proto)
|
static int nonblocking_socket(struct sslhcfg_protocols_item* proto)
|
||||||
{
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
if (proto->resolve_on_forward) {
|
if (proto->resolve_on_forward) {
|
||||||
resolve_split_name(&(proto->saddr), proto->host,
|
res = resolve_split_name(&(proto->saddr), proto->host,
|
||||||
proto->port);
|
proto->port);
|
||||||
|
if (res) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int out = socket(proto->saddr->ai_family, SOCK_DGRAM, 0);
|
int out = socket(proto->saddr->ai_family, SOCK_DGRAM, 0);
|
||||||
int res = set_nonblock(out);
|
res = set_nonblock(out);
|
||||||
if (res == -1) {
|
if (res == -1) {
|
||||||
print_message(msg_system_error, "%s:%d:%s:%d:%s\n", __FILE__, __LINE__, "udp:socket:nonblock", errno, strerror(errno));
|
print_message(msg_system_error, "%s:%d:%s:%d:%s\n", __FILE__, __LINE__, "udp:socket:nonblock", errno, strerror(errno));
|
||||||
close(out);
|
close(out);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user