• src/encode/utf8.c utf8.h

    From Deucе@VERT to Git commit to main/sbbs/master on Thu Feb 10 16:01:28 2022
    https://gitlab.synchro.net/main/sbbs/-/commit/d9660eaf60094e10ef2ec54e
    Modified Files:
    src/encode/utf8.c utf8.h
    Log Message:
    New functions utf8_to_cp437_str() latin1_to_utf8_str() utf8_to_latin1_str()

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Windows)@VERT to Git commit to main/sbbs/master on Wed May 24 13:14:35 2023
    https://gitlab.synchro.net/main/sbbs/-/commit/01cf3f87739aa57703cb97bc
    Modified Files:
    src/encode/utf8.c utf8.h
    Log Message:
    Comment header block update (only)

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Windows 11)@VERT to Git commit to main/sbbs/master on Tue Feb 6 12:35:50 2024
    https://gitlab.synchro.net/main/sbbs/-/commit/5e4964c4b2e80c9d413a3871
    Modified Files:
    src/encode/utf8.c utf8.h
    Log Message:
    Add utf8_decode_firstbyte()

    for use when all you need is the length (and validity) of the first byte in
    a UTF-8 sequence.

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Windows 11)@VERT to Git commit to main/sbbs/master on Thu Feb 15 21:37:00 2024
    https://gitlab.synchro.net/main/sbbs/-/commit/88a7e14ecd5b55bfcca1f261
    Modified Files:
    src/encode/utf8.c utf8.h
    Log Message:
    Create utf8_strlcpy() which does a "safe" truncated-string copy

    (doesn't leave a partial UTF-8 sequence at the end of the destination string).

    This calls memcpy() for every char, which may not be performant, but I didn't (yet) do any profiling. Hence, no premature optimization either.

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Wed Jul 29 23:14:42 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/bb5ff19c182d2d04df90e016
    Modified Files:
    src/encode/utf8.c utf8.h
    Log Message:
    utf8: count the NUL-terminator in the conversion buffer size

    cp437_to_utf8_str() and its three siblings documented 'maxlen' as the
    converted length "sans NUL-terminator", then wrote that terminator at dest[maxlen] - so every caller had to pass one less than the size of its buffer. Five of the thirteen in-tree call sites passed sizeof(buf)
    instead, overrunning it by a byte whenever the UTF-8 expansion landed
    exactly on the buffer size, which for a 128-byte buffer takes only 64
    high-bit source characters.

    The reachable one is encode_header_field() in mailsrvr.cpp, which
    converts outbound message header text into a 256-byte stack buffer; postmsg.cpp, sbbsecho.c, msgtoqwk.cpp and getmsg.cpp have the same shape.

    Rename the parameter to 'size' and treat it as the full extent of the destination, terminator included, the way snprintf() and strlcpy() do.
    That makes the five unsafe call sites correct as written and leaves those already passing sizeof(buf) - 1 a harmless byte short of capacity. A size
    of zero now writes nothing rather than a stray terminator.

    Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net