]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: proto: fix fd leak in <proto>_connect_server
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Tue, 21 May 2024 17:24:31 +0000 (19:24 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 21 May 2024 18:14:05 +0000 (20:14 +0200)
commit5f713c03bed6424fee7dc36fbb00efe368a7e95b
treeec4cd34357a66747909d4412f8931e1346197ab1
parent04a42a92f4cf31adf66a0796309bcb429e28de2f
BUG/MEDIUM: proto: fix fd leak in <proto>_connect_server

This fixes the fd leak, introduced in the commit d3fc982cd788
("MEDIUM: proto: make common fd checks in sock_create_server_socket").

Initially sock_create_server_socket() was designed to return only created
socket FD or -1. Its callers from upper protocol layers were required to test
the returned errno and were required then to apply different configuration
related checks to obtained positive sock_fd. A lot of this code was duplicated
among protocols implementations.

The new refactored version of sock_create_server_socket() gathers in one place
all duplicated checks, but in order to be complient with upper protocol
layers, it needs the 3rd parameter: 'stream_err', in which it sets the
Stream Error Flag for upper levels, if the obtained sock_fd has passed all
additional checks.

No backport needed since this was introduced in 3.0-dev10.
include/haproxy/sock.h
src/proto_quic.c
src/proto_tcp.c
src/proto_uxst.c
src/sock.c