]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: fd: release the port range entry in host byte order
authorDragan Dosen <ddosen@haproxy.com>
Fri, 7 Aug 2026 11:08:45 +0000 (11:08 +0000)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 Aug 2026 11:37:03 +0000 (13:37 +0200)
The port recovered with getsockname() in _fd_delete_orphan() was given
back to the port range without being converted to host byte order. The
range then fills up with byte-swapped values which are handed out on the
next pass. Both TCP and QUIC are affected.

It is now released using get_host_port(), which takes care of the
conversion for both address families.

The issue was introduced with commit 02b7685013 ("MEDIUM: fd: Remove
fdinfo").

No backport needed.

src/fd.c

index 7e106654e871c0a805e4f510864c3cc4888ed8cf..60dbb1a85b62707c89f65fc51e65c31cb66ec1f0 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -352,11 +352,8 @@ void _fd_delete_orphan(int fd)
                 * to figure out what the port was.
                 */
                BUG_ON(getsockname(fd, (struct sockaddr *)&sa, &addrlen) != 0);
-               if (sa.ss_family == AF_INET)
-                       port = ((struct sockaddr_in *)&sa)->sin_port;
-               else if (sa.ss_family == AF_INET6)
-                       port = ((struct sockaddr_in6 *)&sa)->sin6_port;
-               else
+               port = get_host_port(&sa);
+               if (!port)
                        ABORT_NOW();
                port_range_release_port(fdtab[fd].owner, port);
        }