https://gitlab.synchro.net/main/sbbs/-/commit/804f47eac92dd0c1c7820f1e
Modified Files:
src/sbbs3/exec.cpp js_global.cpp js_internal.cpp mailsrvr.cpp sbbs.h services.cpp websrvr.cpp
Log Message:
js: report a script file read error instead of running a partial script
SpiderMonkey 1.8.5's JS_CompileFile() reads a script with getc() until
EOF and never checks ferror(), so a read that fails part-way (e.g. on an overloaded network share) ends the script there. The partial text was
then compiled and executed as if it were the whole file. Symptoms seen
with exec/ on a stalled SMB share:
Error: symbol 'USER_DELETED' not defined by script 'sbbsdefs.js'
presence_lib.js line 163: SyntaxError: unterminated comment
graphic.js line 544: SyntaxError: unterminated string literal
webfileindex.ssjs line 241: TypeError: contents is undefined
along with "!JavaScript FAILED to compile script" with no reason given
(its fstat() failure path returns NULL without reporting an error). A
script cut at a statement boundary ran its first part with no error at
all.
The same function sizes its buffer from fstat() and then stores every
character read with no bound, so a file that grows between the two
overruns the heap buffer in a release build.
Add js_CompileFile(), which reads the file itself, grows its buffer as
needed, and reports the errno and offset of a failed read as a
JavaScript error, and use it in place of JS_CompileFile() for load(), require(), js.exec(), and the terminal, web, mail and services script launchers.
Co-Authored-By: Claude Fable 5.2 <
noreply@anthropic.com>
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net