• SSH: terminal width/height from client not range-checked like other pa

    From Rob Swindell@1:103/705 to GitLab issue in main/sbbs on Thursday, November 19, 2026 11:34:48
    open https://gitlab.synchro.net/main/sbbs/-/work_items/1368

    In `sbbs_t::answer()` (`src/sbbs3/answer.cpp`), the terminal width and height reported by an SSH client (pty-req, via `CRYPT_SESSINFO_SSH_CHANNEL_WIDTH` / `CRYPT_SESSINFO_SSH_CHANNEL_HEIGHT`) are assigned to `term->cols` / `term->rows` with only an `l > 0` check:

    ```cpp
    if (cryptStatusOK(cryptGetAttribute(ssh_session, CRYPT_SESSINFO_SSH_CHANNEL_WIDTH, &l)) && l > 0) {
    term->cols = l;
    ```

    Every other source of terminal dimensions range-checks against `TERM_COLS_MIN`/`TERM_COLS_MAX` and `TERM_ROWS_MIN`/`TERM_ROWS_MAX` (`sbbsdefs.h`): telnet NAWS and ANSI auto-detection in `answer.cpp`, the CPR handling in `ansi_terminal.cpp`, the JS `console.screen_columns`/`screen_rows` setters, and the user settings in `con_out.cpp`. So an SSH client can set dimensions (e.g. 1x1, or 2^31-1 columns) that no other path would accept.

    I found no buffer that a large value overruns (the `wordwrap` copies in `getstr.cpp` are bounded by `sizeof`), so this is hardening/consistency
    rather than a memory-safety bug, but out-of-range dimensions reach every
    layout calculation that trusts `term->cols`/`term->rows`.

    Suggested fix: apply the same `TERM_*_MIN`/`TERM_*_MAX` checks to the SSH width/height, ignoring out-of-range values (leaving the defaults / auto-detection in effect) as the telnet NAWS path does. The unchecked reads date from b99d161b91 (puts-11-being, 2023-12-24), which added the SSH
    terminal type/size support.

    -- *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Rob Swindell@1:103/705 to GitLab issue in main/sbbs on Thursday, November 19, 2026 11:51:47
    close https://gitlab.synchro.net/main/sbbs/-/work_items/1368
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)