• src/sbbs3/netmail.cpp

    From Rob Swindell (on Debian Linux)@1:103/705 to Git commit to main/sbbs/master on Tuesday, September 15, 2026 20:47:46
    https://gitlab.synchro.net/main/sbbs/-/commit/93e3598ffb0d8f368643561a
    Modified Files:
    src/sbbs3/netmail.cpp
    Log Message:
    Hold the SMB header lock across the QWK netmail data allocation

    sbbs_t::qwktonetmail() allocated message data storage without holding smb_locksmbhdr(). Every other allocation site takes it across the
    allocation; this one acquired it only indirectly, when smb_addmsghdr()
    locks internally some fifty lines later, by which point the data blocks
    had already been chosen and written.

    smb_allocdat() scans the .sda for a run of free blocks and only then
    writes their reference counts, so the window between choosing a run and claiming it spans the rest of the scan. Two writers allocating
    concurrently, one of them on this path, can settle on the same run and
    produce two messages whose data storage overlaps, which chksmb reports
    as duplicated or corrupt data records. Header allocation is unaffected,
    being done inside smb_addmsghdr() under the lock it takes itself.

    The window is far narrower under fast allocation, which seeks to EOF and
    claims the blocks immediately, so switching a mail base to that storage
    mode makes this class of error appear to stop without fixing it.

    issue #1241

    Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
    --- SBBSecho 3.37-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)