• src/sftp/sftp_pkt.c

    From Deucе@VERT to Git commit to main/sbbs/master on Fri Dec 29 09:50:22 2023
    https://gitlab.synchro.net/main/sbbs/-/commit/7574858b5f76839a961f0bf5
    Modified Files:
    src/sftp/sftp_pkt.c
    Log Message:
    Fix issue found by coverity.

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Deucе@VERT to Git commit to main/sbbs/master on Fri Dec 29 17:13:53 2023
    https://gitlab.synchro.net/main/sbbs/-/commit/fa28e4e592178fcb726d4281
    Modified Files:
    src/sftp/sftp_pkt.c
    Log Message:
    Use 0 for return, not false.

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Deucе@VERT to Git commit to main/sbbs/master on Sat Dec 30 07:13:45 2023
    https://gitlab.synchro.net/main/sbbs/-/commit/6147a1682b58adab072d86c3
    Modified Files:
    src/sftp/sftp_pkt.c
    Log Message:
    Fix buffer underflow checks in get functions

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Deucе@VERT to Git commit to main/sbbs/master on Sat Dec 30 07:14:13 2023
    https://gitlab.synchro.net/main/sbbs/-/commit/36c7de42b1a57b2e629048f2
    Modified Files:
    src/sftp/sftp_pkt.c
    Log Message:
    Formatting cleanup

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Deucе@VERT to Git commit to main/sbbs/master on Sat Dec 30 07:15:41 2023
    https://gitlab.synchro.net/main/sbbs/-/commit/a530b75b071bd30c47918e2c
    Modified Files:
    src/sftp/sftp_pkt.c
    Log Message:
    More formatting

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Deucе@VERT to Git commit to main/sbbs/master on Wed Feb 7 16:46:54 2024
    https://gitlab.synchro.net/main/sbbs/-/commit/9c4ba9cb0caf7b866006e57c
    Modified Files:
    src/sftp/sftp_pkt.c
    Log Message:
    Attempt to tell gcc I know what I'm doing with a void* cast

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Deucе@VERT to Git commit to main/sbbs/master on Wed Feb 7 16:50:41 2024
    https://gitlab.synchro.net/main/sbbs/-/commit/875342b1e2279adcf7936448
    Modified Files:
    src/sftp/sftp_pkt.c
    Log Message:
    Get a bit more creative in casting (to shut up gcc)

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Deucе@VERT to Git commit to main/sbbs/master on Wed Feb 7 17:10:19 2024
    https://gitlab.synchro.net/main/sbbs/-/commit/e19fbb4047b40500f7030f7b
    Modified Files:
    src/sftp/sftp_pkt.c
    Log Message:
    Revert sftp_pkt.c

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Deucе@VERT to Git commit to main/sbbs/master on Wed Feb 7 17:13:40 2024
    https://gitlab.synchro.net/main/sbbs/-/commit/79ecd8d2fb2be8616cfaca30
    Modified Files:
    src/sftp/sftp_pkt.c
    Log Message:
    One last attempt... cast the whole thing to uint8_t and take a
    pointer to an element. No way gcc has a clue about what I'm doing
    then.

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Deucе@VERT to Git commit to main/sbbs/master on Wed Feb 7 17:14:45 2024
    https://gitlab.synchro.net/main/sbbs/-/commit/6c467ceac37e00625458ed7d
    Modified Files:
    src/sftp/sftp_pkt.c
    Log Message:
    Fix typo.

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Deucе@VERT to Git commit to main/sbbs/master on Wed Feb 7 17:16:34 2024
    https://gitlab.synchro.net/main/sbbs/-/commit/31870b7b6ff5721364ae3a3e
    Modified Files:
    src/sftp/sftp_pkt.c
    Log Message:
    Fix backslash alignment when 8-position tabs are used.

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Deucе@VERT to Git commit to main/sbbs/master on Sun Feb 11 14:19:07 2024
    https://gitlab.synchro.net/main/sbbs/-/commit/862f4a2c75193b50d9445b09
    Modified Files:
    src/sftp/sftp_pkt.c
    Log Message:
    Disable a few more warnings... the rest look useful.

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net
  • From Deucе@VERT to Git commit to main/sbbs/master on Fri May 1 07:59:47 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/16319af40a18856276aea0fa
    Modified Files:
    src/sftp/sftp_pkt.c
    Log Message:
    sftp: fix tx and rx buffer round-up bugs at 4 KiB boundaries

    Two parallel undersizing bugs in the shared SFTP packet library
    caused both peers to corrupt their own buffers near
    SFTP_MIN_PACKET_ALLOC (4 KiB) boundaries.

    rx_pkt_append used

    new_sz = new_sz / SFTP_MIN_PACKET_ALLOC + SFTP_MIN_PACKET_ALLOC

    — a divide where there should have been a `+= (BLOCK - remain)`.
    For any inbound chunk whose total exceeded the first 4 KiB boundary
    the formula collapsed back to roughly 4 KiB, the realloc undersized
    the buffer, and the subsequent memcpy walked past the heap
    allocation.

    grow_tx had a structurally different but related bug: in the
    existing-packet branch it computed

    newsz = pkt->used + need;

    omitting the offsetof(struct sftp_tx_pkt, type) header that pkt->sz
    already accounts for. The realloc rounded `pkt->used + need` up to
    the next 4 KiB boundary, but the actual write target lands at
    `pkt->used + offsetof(type) + need`, so when (used + need) lands on
    a 4 KiB boundary the new allocation undershoots by up to
    offsetof(type) bytes. The fresh-allocation branch and the trailing
    asserts both already used the offsetof-inclusive form; bring the existing-packet branch in line.

    The library is shared, so each bug corrupted both peers: rx_pkt for
    large inbound packets (uploads, large readdir replies, file data),
    grow_tx for outbound packets that crossed a 4 KiB boundary.
    Symptom in the wild was a SyncTERM SFTP browser failing to list a
    25-entry filebase directory with garbled fattr / filename strings
    near entry 23-24.

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

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