]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Assert fd validity in start_udp_child()
authorMichal Nowak <mnowak@isc.org>
Mon, 29 Jun 2026 11:40:50 +0000 (11:40 +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/udp.c:194: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/udp.c

index 7922683bdc91f3b742be25e4fb675abe3893c066..fa79717fb7764a75d5e77cf0d66be13bccf04b39 100644 (file)
@@ -191,6 +191,7 @@ start_udp_child(isc_sockaddr_t *iface, isc_nmsocket_t *sock, uv_os_sock_t fd,
        if (isc__netmgr->load_balance_sockets) {
                csock->fd = isc__nm_udp_lb_socket(iface->type.sa.sa_family);
        } else {
+               INSIST(fd >= 0);
                csock->fd = dup(fd);
        }
        INSIST(csock->fd >= 0);