Repository navigation
Reject overflowing write ranges before allocation or copy - #8
Merged
Merged
Conversation
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
marked this pull request as ready for review
November 12, 2026 14:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.