• src/sbbs3/js_socket.cpp

    From Rob Swindell (on Windows 11)@VERT to Git commit to main/sbbs/master on Thu Dec 18 18:17:32 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/130d267d095b28c5c829b2d3
    Modified Files:
    src/sbbs3/js_socket.cpp
    Log Message:
    Code clean-up

    - TRUE -> true
    - Eliminate unnecessary free(NULL) checks
    - Fix the potential socket leaks in error handling in socket constructors
    as reported by ChatGPT via Nelgin

    Something I noticed while doing this: functions in this file call call_socket_open_callback() from main.cpp either directly or via a callback from xpms API calls. This only work if the terminal server is running and has been initialized. So ... running other servers in their own process without
    the terminal server (as some sysops do) won't count open sockets accurately. <shrug>

    ---
    ■ 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 Sat Dec 20 12:33:04 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/3a4f6ecdd4aacf481635299a
    Modified Files:
    src/sbbs3/js_socket.cpp
    Log Message:
    Fix CID 640043 (USE_AFTER_FREE)

    xpms_destroy() frees the passed pointer, so no need to free() it after.

    ---
    ■ 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 May 6 19:41:53 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/fbfdfc8140cdcb50c11933f4
    Modified Files:
    src/sbbs3/js_socket.cpp
    Log Message:
    js_socket: fix js_sendto getaddrinfo error-capture parens (CID 639937)

    The expression was

    if ((result = getaddrinfo(...) != 0))

    which parses as result = (getaddrinfo(...) != 0), so result becomes 0
    or 1 instead of the actual EAI_* error code. The subsequent gai_strerror(result) and "%d" format then report the wrong error.

    Move the closing paren so the assignment captures the real return:

    if ((result = getaddrinfo(...)) != 0)

    Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

    ---
    ■ 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 May 6 22:36:57 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/99b45532cd579daceacd8f72
    Modified Files:
    src/sbbs3/js_socket.cpp
    Log Message:
    js_socket: close socket on fail-path in connected_socket_constructor (CID 530501)

    The 'fail:' label freed p without closing p->sock, leaking the socket
    handle when set_socket_options() failed after a successful socket()
    call. Initialize p->sock to INVALID_SOCKET right after the memset
    (so the getaddrinfo-failure path doesn't accidentally close fd 0)
    and have the fail label closesocket() when the socket is valid.

    Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

    ---
    ■ 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 May 6 23:22:41 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/5a2b68dfa4f6350486ed05e3
    Modified Files:
    src/sbbs3/js_socket.cpp
    Log Message:
    js_socket: cast setsockopt TCP_NODELAY to void in TLS session setup (CID 639936)

    Same pattern as the websrvr TCP_NODELAY fix in 91988f5ef: TCP_NODELAY
    is a best-effort latency optimization for the TLS handshake; if the
    setsockopt is rejected (e.g. on a non-TCP socket) the session still
    works. Make the discarded return explicit.

    Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

    ---
    ■ 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 Sun Oct 25 13:37:51 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/6a90215fb1d8b41969c854f6
    Modified Files:
    src/sbbs3/js_socket.cpp
    Log Message:
    js: restore the socket's blocking mode after an asynchronous connect

    The connect thread restored the caller's nonblocking setting by passing
    the address of the one-byte bool in its argument block to ioctlsocket()
    as a ulong. The read took in the padding and the port field behind it,
    so the value was nonzero for any nonzero port and the socket was always
    left nonblocking, whatever mode the script had set. A Socket.connect()
    with a callback on a blocking socket therefore returned a nonblocking
    one: send() of more than the kernel would buffer failed with EWOULDBLOCK instead of waiting.

    Copy the flag into a ulong first. Dates from 1928973941 (2021-04-02).

    Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

    ---
    ■ 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 Sun Oct 25 16:13:09 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/dd03edda573f914bc975282e
    Modified Files:
    src/sbbs3/js_socket.cpp
    Log Message:
    js: route every FIONBIO ioctl through one helper

    Five sites passed the address of private_t's BOOL nonblocking field to ioctlsocket() through a (ulong*) cast. That is correct only while the
    field stays four bytes wide; the connect-thread copy of the same field
    was converted to bool in 118984e9af (2024-01-19) and broke exactly this
    way, fixed in 6a90215fb1 (2026-10-25).

    Add set_socket_nonblocking(), which copies the flag into a local and
    passes that, so the pointer type is compiler-checked and the field's
    width no longer matters. The local is u_long on Windows and int
    elsewhere, the width each platform's FIONBIO consumer actually reads.
    The ulong locals used until now are 8 bytes on LP64 and only worked on little-endian targets.

    Use the helper for all nine FIONBIO calls in the file, dropping three single-use locals. The TLS session setup also set TCP_NODELAY via a
    ulong; use an int there, as elsewhere since 77d90bedea (2026-05-05).

    Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

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