• exec/tests/file/ini_unescape.jssrc/xpdev/genwrap.c

    From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Fri Nov 20 15:25:23 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/461eb40f7d57e2d17c12e85f
    Added Files:
    exec/tests/file/ini_unescape.js
    Modified Files:
    src/xpdev/genwrap.c
    Log Message:
    xpdev: c_unescape_char_ptr() no longer steps past a string's end

    A string ending in a lone backslash made c_unescape_char_ptr() step past
    the terminating NUL, so c_unescape_str() and c_unescape_printable() went
    on reading (and, in place, writing) beyond the end of the string until
    the next NUL in memory. The backslash still yields NUL, so the string
    ends at it, as before. This has been the case since the unescape
    functions were created in 279370dc3f (room-3-your, 2004-08-04).

    Callers reach it with input from files: ini "key : value" string
    literals (ini_file.c unescapes the key, then the value, in the same line buffer), filter files read by findstr(), and @-code and message display (atcodes.cpp, putmsg.cpp). An ini line such as "key\:value" returned
    "alue" for "key": unescaping the key ran on into the value and shifted
    it over by one character.

    Test: exec/tests/file/ini_unescape.js (ini literals ending in a
    backslash, also inside quotes, at end of file and at the end of a key; findstr() on a file whose last line ends in a backslash). Without the
    fix the key case fails ("alue", expected "value"). An AddressSanitizer
    harness calling c_unescape_str() on a heap copy of "abc\" reported a heap-buffer-overflow read before the fix and none after it.

    Built with GCC only.

    Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net