https://gitlab.synchro.net/main/sbbs/-/commit/96c85102da3a401c7ce1df48
Modified Files:
src/doors/syncconquer/PROVENANCE.md src/doors/syncconquer/door/door_io.c src/doors/syncconquer/vanilla/common/ini.h paths.cpp
Log Message:
syncalert: fix the startup abort on Ubuntu; -home is optional again
Nightfox reported syncalert dying immediately with "*** buffer overflow detected ***: terminated" (SIGABRT) on his BBS, from a Release binary,
and supplied a core. Reading the libc build-id out of the core's first
mapped page and pulling the matching debuginfo named the frame:
__realpath_chk -> __chk_fail -> __fortify_fail -> abort.
door_realpath() resolved paths into a local `char buf[1024]`. glibc
requires a caller-supplied realpath() buffer to hold at least PATH_MAX
(4096) bytes, and _FORTIFY_SOURCE enforces that via __realpath_chk(),
which abort()s whenever the destination's known object size is under
PATH_MAX -- unconditionally, no matter how short the resolved path
actually is. Ubuntu's gcc default-enables -D_FORTIFY_SOURCE at -O2 and
Debian's does not, so identical source killed the door on his host and
ran fine here. Pass NULL instead (POSIX.1-2008 has realpath() malloc the result) and free it, which sidesteps PATH_MAX entirely; Windows keeps _fullpath() with a _MAX_PATH buffer. Verified by rebuilding with -D_FORTIFY_SOURCE=2, which reproduces the abort exactly before the fix
and runs clean after. The vendored engine was already correct here (paths_posix.cpp uses char[PATH_MAX]; Argv_Path() writes into a
std::string), so this was the only affected call site.
Two further startup bugs surfaced while reproducing it:
Without -home, door_setup_engine_paths() returned early and wrote no REDALERT.INI at all, so the engine never learned DataPath and Bootstrap() aborted on LOCAL.MIX -- even with a valid assets dir beside the binary.
A bare launch could not work. -home now defaults to the launch directory, matching SyncDuke and SyncDOOM.
INIClass::MAX_LINE_LENGTH was 128, truncating every INI line at 128
characters, and PathsClass::Init() read [Paths] into a matching
char[128]. The DataPath=/UserPath= values the door writes are filesystem
paths, so a deep-enough install silently lost its assets directory and
died in Bootstrap() the same way. Raised to 4224 (a PATH_MAX value plus
its key) and the paths.cpp buffer sized as char[PATH_MAX]. Both vendored
edits are recorded in PROVENANCE.md as local patch 9.
Verified against both toolchain configurations (fortified, as Ubuntu
builds it, and plain as Debian does): a bare no-arg launch, Nightfox's
exact `-home <dir>/` invocation, -home with -assets, and a 135-character DataPath all now reach the render loop instead of aborting.
Reported-by: Nightfox (Digital Distortion BBS)
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net