• Baja getintvar() exposes 64-bit members as int32_t*: reads truncate, w

    From Rob Swindell@1:103/705 to GitLab issue in main/sbbs on Wed Nov 11 14:36:11 2026
    open https://gitlab.synchro.net/main/sbbs/-/work_items/1337

    `sbbs_t::getintvar()` (`src/sbbs3/exec.cpp`) maps Baja's named system integer variables to `int32_t*` pointers into `sbbs_t`. Baja code then reads and writes them as 32-bit ints (e.g. `*lp = *(int32_t *)csi->ip;` in `execmisc.cpp`). Ten of those members are 8 bytes wide, so the `(int32_t *)` cast reaches only half of each:

    | `exec.cpp` | member | type |
    |---|---|---|
    | 206 | `useron.ulb` | `uint64_t` |
    | 208 | `useron.dlb` | `uint64_t` |
    | 210 | `useron.cdt` | `uint64_t` |
    | 214 | `useron.freecdt` | `uint64_t` |
    | 243 | `answertime` | `time_t` |
    | 245 | `logontime` | `time_t` |
    | 247 | `ns_time` | `time_t` |
    | 249 | `last_ns_time` | `time_t` |
    | 358 | `logon_ulb` | `int64_t` |
    | 360 | `logon_dlb` | `int64_t` |

    The `user_t` counters were widened to `uint64_t` by 2d4ec7b8f2 (disc-3-oaks, 2022-03-23, "Support user credits and transfer stats > 4GB in total"); the `getintvar()` casts were left as `(int32_t *)`. `time_t` is 64-bit on every current target (including MSVC Win32).

    Effects, on little-endian hosts:

    - **Reads truncate.** A user with more than 4 GiB of credits or transfer bytes (or 2 GiB, read as signed) gets the low 32 bits in Baja, so a comparison or display of `cdt`/`ulb`/`dlb` is wrong.
    - **Writes are partial.** A Baja assignment to one of these stores only the low 32 bits and leaves the high half as it was, so the result is neither the old value nor the new one once the old value exceeds 32 bits.
    - **The time members** are correct until January 2038, when the low 32 bits read as negative.

    On a big-endian host the pointer addresses the *high* half instead, so reads of normal-sized values return 0 and writes land in the wrong half.

    Since the conversion is an explicit cast, no compiler warns about it. Found while auditing the BOOL->bool conversion (118984e9af, soil-11-pick, 2024-01-19) for width mismatches the compiler can't see; this one is unrelated to that commit.

    Possible fixes: have `getintvar()` report the variable's width so `execmisc.cpp` can read/write 8-byte members correctly (clamping to the 32-bit Baja value on read), or expose the 64-bit members through 32-bit shadow copies that are synchronized on access.

    -- *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)