MINOR: dns: dns_connect_nameserver: fix fd leak at error path
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Fri, 22 Aug 2025 07:55:40 +0000 (09:55 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 26 Aug 2025 06:54:36 +0000 (08:54 +0200)
commitc97e6b15503b4cd233f1eccf09d07bc16a375933
tree6b93b10c5e14fa0519af010fc7c5df0d6e78ed41
parentb731fa8c186eecef5bf50ee75a77c7aae620fce4
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.

(cherry picked from commit 0dc8d8d027114262bc470d94ecc2664523961446)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 8452cf3ea382d381e6dfc496374d4da2c862909f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/dns.c