• src/smblib/smblib.c

    From Rob Swindell (on Debian Linux)@1:103/705 to Git commit to main/sbbs/master on Thu Nov 19 09:20:50 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/ce3494e738760fd80e4c44f0
    Modified Files:
    src/smblib/smblib.c
    Log Message:
    smblib: free text_subtype/text_charset in smb_freemsghdrmem()

    smb_freemsghdrmem() ended with clear_convenience_ptrs(), which NULLs text_subtype and text_charset along with the pointers into header-field
    data. Those two are not such pointers: smb_parse_content_type() strdup()s
    them from a text/* Content-Type field, so they leaked each time a header
    with one was freed this way. MsgBase.put_msg_header() does that on every
    call (it re-reads the header and frees its fields before re-parsing the
    JS header object), leaking both strings per call; valgrind flagged it in
    the jsexec-testsuite-valgrind CI jobs.

    Free them alongside the header fields they are derived from.
    smb_freemsgmem() calls smb_freemsghdrmem(), so its own frees of the two
    are dropped.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Rob Swindell (on Debian Linux)@1:103/705 to Git commit to main/sbbs/master on Sun Nov 22 12:19:51 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/3980634758b2757f7645fb67
    Modified Files:
    src/smblib/smblib.c
    Log Message:
    smblib: smb_copymsgmem() leaves nothing allocated when it fails

    On a failed malloc(), smb_copymsgmem() returned with whatever it had
    already allocated for the copy still in it (leaked by callers that do not
    free the copy), and with the copy's dfield, hfield and hfield_dat still pointing at the source message's arrays wherever it had not replaced
    them yet. A caller that frees both after a failure, as MsgBase.copy_msg()
    and move_msg() do, then freed the source's arrays twice, and one that
    freed the copy after a failure part-way through the header fields freed
    the uninitialized entries of hfield_dat.

    The copy now starts with no arrays of its own, allocates hfield_dat
    zeroed, and on any failure frees what it allocated, leaving the copy
    holding no allocations, so smb_freemsgmem() on it is safe and not freeing
    it leaks nothing.

    Coverity CIDs 662423, 662427, 662429 (bulkmail.cpp).

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