• exec/tests/system/findstr.jssrc/sbbs3/findstr.c

    From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Fri May 22 18:23:43 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/eee438b0b04b274843abd65b
    Added Files:
    exec/tests/system/findstr.js
    Modified Files:
    src/sbbs3/findstr.c
    Log Message:
    findstr: add IPv6 CIDR support for ip.can / .can matching (issue #1145)

    The .can filter matching path (findstr.c) was IPv4-only Ä parse_cidr used sscanf("%u.%u.%u.%u/%u", ...) and is_cidr_match did a 32-bit XOR-shift, so
    an IPv6 CIDR entry like `2001:db8::/32` in ip.can / ip-silent.can was
    silently treated as a literal-string pattern and never matched a real connecting IPv6 client. This made the web server's rate-limit auto-filter asymmetric: rate_limit_key() correctly bucketizes IPv6 traffic by RateLimitSubnetPrefix6 and writes the subnet to ip.can, but the
    accept-time read-back didn't enforce it.

    Add parallel IPv6 functions: parse_ipv6_address (inet_pton), parse_ipv6_cidr, is_ipv6_cidr_match (byte-then-bit prefix compare). findstr_compare dispatches to the right family by which one the input parsed as; find2strs_in_list and find2strs pre-parse both forms up-front into a small internal findstr_ip_t.

    Also fix two latent bugs surfaced by the new test cases:

    - is_cidr_match's `>> (32 - subnet)` is undefined behavior when subnet
    is 0 (a 32-bit shift by 32); on x86 it modulo-32s to 0, so /0
    never matched anything except via exact host hit. Now guarded.

    - parse_cidr returned uint32_t with 0 overloaded as both "parse failed"
    and "0.0.0.0", so the literal pattern `0.0.0.0/0` (the canonical
    "match-any IPv4") fell through to string-only matching. Changed to
    bool + out-param, matching the new IPv6 convention.

    Add exec/tests/system/findstr.js covering string-pattern features,
    IPv4 CIDR (including /0 and boundaries), IPv6 exact + CIDR (/32 through
    /128, with bit-boundary stress at /33), reverse-match (!) for both
    families, cross-family no-false-match, and malformed-pattern rejection.

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

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