https://gitlab.synchro.net/main/sbbs/-/commit/de1662c069cb723cd2acd958
Modified Files:
src/sbbs3/xtrn.cpp
Log Message:
Log an error when an external program's command line is truncated
sbbs_t::external() assembles the child's command line into
fullcmdline[MAX_PATH + 1] -- 260 usable characters -- via SAFEPRINTF / SAFECOPY, both of which truncate SILENTLY. That string IS the child's entire command line, so an over-long one runs the program with its trailing
arguments missing.
The failure is very hard to diagnose because the evidence contradicts the symptom: the "Executing external" log line prints the command we MEANT to
run, while the child received a shortened one. Observed with a SyncRetro
door whose lobby built a 334-character line -- the ROM path fell off the end and the door reported its content missing while the log showed that
content's full path, which sent the search in entirely the wrong direction.
Log the truncation on both branches, with the length it was cut to, the
length it needed, and the command as actually issued.
The needed length is MEASURED from the inputs rather than read from snprintf()'s return, which looks backwards and is commented as such at both sites: genwrap.h redirects snprintf() to xpdev's safe_snprintf() unless USE_SNPRINTF is defined, and that wrapper clamps its return to size-1 (31 callers accumulate with `d += snprintf(...)` and would otherwise run past
the buffer). USE_SNPRINTF is set only for darwin and freebsd, so the return value is the C99 would-be length on those and the truncated length on Linux
and Windows -- a check written the obvious way would work on a developer's
Mac and be silently dead in production.
This only reports; nothing is resized. Note that cmdstr() has its own,
earlier limit (cmdstr_output[512]) which is likewise silent, so a very long configured command line can already be shortened before external() ever
sees it.
Windows branch compiles clean; the *nix branch is UNCOMPILED here (no
GCC/Clang on this host) and the log message has not yet been observed
firing.
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net