• src/sbbs3/websrvr.cpp

    From Rob Swindell (on Debian L@VERT to Git commit to main/sbbs/m on Tue Nov 10 22:33:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/be39289cd8f8fc4e20597fa5
    Modified Files:
    src/sbbs3/websrvr.cpp
    Log Message:
    websrvr: reset parsed_vpath between requests on a keep-alive connection

    session->parsed_vpath is set when a request path falls under the file area virtual path prefix (FileVPathPrefix, e.g. /files/), but it lives in the session rather than in session->req, so close_request() never cleared it.
    Every later request on the same keep-alive connection was then treated as
    a file-area request by check_request(), which skips the "outside of web
    root" check and the entire webctrl.ini walk.

    Consequences:
    - AccessRequirements in webctrl.ini were bypassed. On wiki.synchro.net,
    GET /data/pages/wiki/syntax.txt returned 401 on its own, but 200 when
    sent after GET /files/ on the same connection.
    - Per-directory Rewrite, JSPreExec and [*.php] FastCGISocket settings were
    ignored, so a .php file fell back to the plain CGI handler from
    web_handler.ini, logging e.g. "CGI Error: .../wiki/index.php: line 1:
    /usr/local/bin/php-cgi: No such file or directory" in error.log.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • From Rob Swindell (on Debian L@VERT to Git commit to main/sbbs/m on Thu Nov 19 19:19:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/d7ce390ffa7c29afeeea9014
    Modified Files:
    src/sbbs3/websrvr.cpp
    Log Message:
    websrvr: keep an idle kept-alive HTTPS connection open

    Over HTTPS the server answered with "Connection: Keep-Alive" and then
    closed the connection as soon as it went back to read the next request
    and found it had not arrived yet. A browser that reused the connection
    after any pause lost the request (Safari does not resend a POST). Plain
    HTTP was not affected.

    sockreadline() and recvbufsocket() skip the wait for a readable socket
    while session->tls_pending is set, and tls_pending stays set after a
    request has been read. The next read went straight to cryptPopData(),
    which is non-blocking (CRYPT_OPTION_NET_READTIMEOUT is 0): with nothing received it returns CRYPT_OK with 0 bytes, or CRYPT_ERROR_TIMEOUT for a
    partial record. sess_recv() returned -1 for both, and the callers treat
    -1 on a TLS session as an error and close it. So a TLS session got no
    idle time at all: the next request, or the rest of a request line or
    POST body, had to be in hand already. The same "no data yet" case also
    hit session_check() (used to wait for more of a POST body), which took
    CRYPT_OK with 0 bytes from a partial record for a closed connection.

    Reading without a select() first goes back to the TLS support of
    dbbfabf1b1 (funky-27-foam, 2015-08-20); then cryptlib's default read
    timeout bounded the idle time. 98b9d23ddd (tight-73-wife, 2018-02-15)
    lowered it to 1 second "since we select() first anyway", and
    3be7d67b5f (flour-3-formed, 2018-03-13) to 0, which left no idle time.
    The session_check() case came with 50258e70bf (notion-31-talks,
    2026-06-04).

    Now sess_recv() clears tls_pending when cryptPopData() delivers nothing (CRYPT_OK with 0 bytes, or CRYPT_ERROR_TIMEOUT), and sockreadline() and recvbufsocket() then go back to waiting on the socket, up to
    MaxInactivity, as for a plain connection. A peer close or a TLS error (CRYPT_ERROR_COMPLETE, CRYPT_ERROR_READ) leaves tls_pending set and
    still ends the session at once. session_check() treats CRYPT_OK with 0
    bytes like CRYPT_ERROR_TIMEOUT: connected, no data yet.

    Reproduced and verified on a scratch web server on loopback with TLS
    (Python client, certificate checks off). Before: a second request on
    one TLS connection after a 0.3, 2 or 10 second pause got EOF, as did a
    request line or POST body sent in two parts with a pause (also when cut
    in the middle of a TLS record). After: two and five requests per
    connection with pauses of 0, 0.3, 2 and 10 seconds all answered,
    static and .ssjs, GET and POST; the split request line and POST bodies
    are read; an idle connection is closed after MaxInactivity with the
    "Session timeout due to inactivity" log line, as is half a request
    line; a client close (FIN alone or close_notify) ends the session
    thread as before; no CPU used while a connection waits; plain HTTP
    unchanged. As a plain one already did, an idle kept-alive HTTPS
    connection now holds its session thread, and delays a server shutdown,
    for up to MaxInactivity. Built with GCC only.

    Fixes #1370

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • From Rob Swindell (on Debian L@VERT to Git commit to main/sbbs/m on Fri Nov 20 15:25:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/4402dd90b746cc73cf22a61d
    Modified Files:
    src/sbbs3/websrvr.cpp
    Log Message:
    websrvr: end a session whose request body stops arriving

    A client that sent request headers with a Content-Length and then fewer
    body bytes than that held its session thread for as long as it kept the connection open, with no limit: MaxClients such connections, from anyone
    and before any authentication, stop the web server.

    recvbufsocket() waited for more body data with session_check(), which
    returns true both when data is readable and when the wait times out with nothing to read; the loop could not tell the two apart. Over HTTPS the
    read that followed found no record and went round again, each pass
    waiting MaxInactivity: this came with the keep-alive fix, d7ce390ffa (wave-63-zinc, 2026-11-19), which made "no TLS data yet" mean wait for
    more instead of close. Over plain HTTP the read that followed was a
    blocking recv() with no timeout at all, which is older.

    Now recvbufsocket() asks session_check() whether the socket is readable
    and, when the wait ended with nothing to read, logs "Session timeout due
    to inactivity" (as sockreadline() does for a request line or header) and
    closes the session. The bound is the idle time between pieces of the
    body, not the time for the whole body: a client that keeps sending stays connected. A plain recv() that returns EAGAIN now waits again instead of
    adding -1 to the byte count.

    sockreadline(), the other loop the keep-alive fix changed, already
    bounds each wait with socket_readable() and needs no change.

    Reproduced on a scratch web server on loopback (MaxInactivity 10 s,
    Python client): a POST with Content-Length 1000 and 500 body bytes, then silence. Before: over both HTTPS and HTTP the connection was still open,
    and the session thread still counted, when the client gave up after
    120 s. After: both closed after 10 s with the log line. A body sent in
    two halves 4 s apart is answered (both, before and after); a body that
    trickles one byte every 6 s stays connected, then is closed 10 s after
    the last byte. The keep-alive battery of the earlier fix (2 and 5
    requests per connection with pauses up to 10 s, split request line,
    request and POST body cut mid-TLS-record) passes unchanged. Built with
    GCC only.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • From Rob Swindell (on Debian L@VERT to Git commit to main/sbbs/m on Fri Nov 20 15:25:00 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/262a312abf6be850372beaa5
    Modified Files:
    src/sbbs3/websrvr.cpp
    Log Message:
    websrvr: do not run a request whose body never arrived

    read_post_data() read a body of known length (not chunked, at most MAX_POST_LEN) with recvbufsocket() and returned true whatever it got.
    When the body stopped arriving (the peer was idle past MaxInactivity, or
    closed the connection), recvbufsocket() closed the session socket and
    returned 0, and the request was handled anyway: the script ran with an
    empty body and its reply went to a closed socket. Now nothing read
    means no request: read_post_data() returns false, as it already did
    when a larger body (spooled to a file) or a chunk could not be read.
    Older than the earlier body-read fix, which made the wait end at
    MaxInactivity over HTTPS instead of never.

    Reproduced on a scratch web server on loopback (MaxInactivity 10 s),
    with a script that appends a line to a file each time it runs: a POST
    with Content-Length 1000 and 500 body bytes, then silence. Before: over
    HTTPS and plain HTTP the connection was closed after 10 s and the
    script still ran, each time with an empty body ("ran 0"). After: closed
    after 10 s, the script not run. A body sent in two halves 1 s apart
    runs it with all 1000 bytes, over HTTP and HTTPS. The keep-alive checks
    of the earlier fixes pass unchanged. Built with GCC only.

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