https://gitlab.synchro.net/main/sbbs/-/commit/b96da4eb924aa5ac3da6302c
Modified Files:
src/xpdev/multisock.c sockwrap.h
Log Message:
Create listen sockets close-on-exec atomically where possible (#1174)
0db85afb4c (social-29-army, 2026-08-07) set FD_CLOEXEC with fcntl() after socket() returns, which leaves a window: a fork/exec on another thread
during those few instructions still hands the descriptor to the child. Rare, but the bug it fixes was already rare.
Most POSIX platforms can ask for the flag at creation time and close the
window entirely. XP_SOCK_CLOEXEC is that flag where one exists and 0 where
none does, so the socket() call needs no per-platform spelling, and the
fcntl() stays unconditional rather than becoming a branch that compiles on
one platform and is therefore never built anywhere else. Where the creation flag worked the fcntl() is a redundant no-op; where there is none (macOS) it remains the only protection, and still racy there.
It lives in sockwrap.h rather than multisock.c so that accept4() and the long-lived open() call sites can use the same spelling when those are
audited.
Suggested by Deuce.
Co-Authored-By: Claude Opus 5 (1M context) <
noreply@anthropic.com>
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net