]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: proto_uxst: delete fd from fdtab if listen() fails
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Fri, 9 Aug 2024 09:05:41 +0000 (11:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Aug 2024 13:23:28 +0000 (15:23 +0200)
This patch is done mostly as a safeguard in order not to trigger
BUG_ON(fdtab[fd].owner != NULL) check, if listen() will fail on UNIX domain
socket.

In uxst_bind_listener(), the pretty same logic of closing socket on error path
was kept, as it was in tcp_bind_listener() before. The use of fd_delete() was
not generalized, when the support of UNIX sock_stream protocol was implemented.
So, let's remove fd from fdtab on failure, instead of closing it. Otherwise,
uxst_bind_listener(), which could be called in loop for each receiver, will
obtain the same fd via socket() for the next receiver. Then, it will bind it
again and it will try to re-insert it in fdtab.

This can be backported to all stable versions.

src/proto_uxst.c

index 7828e31831db09091468a1a6819ea4f6d08b29e5..9c739c3fe3d15d7c0b7622ef244a6f1b42c91503 100644 (file)
@@ -143,7 +143,7 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
        return err;
 
  uxst_close_return:
-       close(fd);
+       fd_delete(fd);
  uxst_return:
        if (msg && errlen) {
                char *path_str;