Skip to content

Reject overflowing write ranges before allocation or copy - #8

Merged
minelogy-dev merged 2 commits into
mainfrom
fix/write-range-overflow
Nov 12, 2026
Merged

minelogy-dev merged 2 commits into
mainfrom
fix/write-range-overflow

Conversation

@minelogy-dev

Copy link
Copy Markdown
Owner

A call such as sx_write_cstr(s, SIZE_MAX, "X") wraps idx + len to zero. The existing reserve check can then succeed, after which the copy forms an out-of-bounds destination. The shared write helper now rejects overflow before arithmetic or copying; sx_write_view checks before its alias-preserving pre-reserve so rejection also preserves target capacity.

Owned arguments retain their consumption semantics, and valid binary writes and aliased growth retain their behavior. API signatures/layouts are unchanged. This is independent of the open search optimization in #7.

Adds default/exact-reserve sanitizer regressions near SIZE_MAX using real small buffers. A dedicated job reproduces the baseline sanitizer failure, requires the fixed versions to pass with GCC 14 and Clang 19, and compares equal-length binary overwrites with SDS, bstrlib and raw memcpy on the same host under hot and flushed conditions. Validation is running; raw generated harness/source hashes and samples are retained. See docs/WRITE_SAFETY.md for scope and contracts.

minelogy-dev and others added 2 commits November 2, 2026 12:17
Validate idx + input length before pointer arithmetic, including the
view path's pre-reserve. Preserve owned-input consumption and valid
binary/aliased writes. Add sanitizer regressions and a focused same-host
cross-library cost check with baseline failure reproduction.

Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
@minelogy-dev
minelogy-dev marked this pull request as ready for review November 12, 2026 14:32
@minelogy-dev
minelogy-dev merged commit d518e21 into main Nov 12, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant