mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
MINOR: dns: dns_connect_nameserver: fix fd leak at error path
This fixes the commit 2c7e05f80e3b ("MEDIUM: dns: don't call connect to dest socket for AF_INET*"). If we fail to bind AF_INET sockets or the address family of the nameserver protocol isn't something, what we expect, we need to close the fd, obtained by connect. This fixes the issue GitHub #3085 This must be backported along with the commit 2c7e05f80e3b.
This commit is contained in:
parent
a498e527b4
commit
0dc8d8d027
@ -77,6 +77,7 @@ static int dns_connect_nameserver(struct dns_nameserver *ns)
|
|||||||
send_log(NULL, LOG_WARNING,
|
send_log(NULL, LOG_WARNING,
|
||||||
"DNS : section '%s': can't bind socket for nameserver '%s' on 0.0.0.0:0.\n",
|
"DNS : section '%s': can't bind socket for nameserver '%s' on 0.0.0.0:0.\n",
|
||||||
ns->counters->pid, ns->id);
|
ns->counters->pid, ns->id);
|
||||||
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -93,6 +94,7 @@ static int dns_connect_nameserver(struct dns_nameserver *ns)
|
|||||||
send_log(NULL, LOG_WARNING,
|
send_log(NULL, LOG_WARNING,
|
||||||
"DNS : section '%s': can't bind socket for nameserver '%s' on :::0.\n",
|
"DNS : section '%s': can't bind socket for nameserver '%s' on :::0.\n",
|
||||||
ns->counters->pid, ns->id);
|
ns->counters->pid, ns->id);
|
||||||
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -110,6 +112,7 @@ static int dns_connect_nameserver(struct dns_nameserver *ns)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
close(fd);
|
||||||
BUG_ON(1, "DNS: Unsupported address family.");
|
BUG_ON(1, "DNS: Unsupported address family.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user