]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Assert fd validity in start_tcp_child()
authorMichal Nowak <mnowak@isc.org>
Mon, 29 Jun 2026 11:41:09 +0000 (11:41 +0000)
committerMichal Nowak <mnowak@isc.org>
Thu, 23 Jul 2026 12:22:12 +0000 (14:22 +0200)
load_balance_sockets is fixed at netmgr init, so dup(fd) runs only when
the caller supplied a valid descriptor.  Assert it to silence a
scan-build false positive:

    lib/isc/netmgr/tcp.c:468:15: warning: The 1st argument to 'dup' is -1 but should be >= 0 [unix.StdCLibraryFunctions]

Assisted-by: Claude:claude-opus-4-8
lib/isc/netmgr/tcp.c

index 9ec8a7f3b5d0a900a2d7fc236cf7ebfe28bead27..4906b9e4f4e55032146b369b79698829133662d0 100644 (file)
@@ -465,6 +465,7 @@ start_tcp_child(isc_sockaddr_t *iface, isc_nmsocket_t *sock, uv_os_sock_t fd,
                UNUSED(fd);
                csock->fd = isc__nm_tcp_lb_socket(iface->type.sa.sa_family);
        } else {
+               REQUIRE(fd >= 0);
                csock->fd = dup(fd);
        }
        REQUIRE(csock->fd >= 0);