guard minified skip_ws against end of non-null-terminated input#2634
Merged
stephenberry merged 2 commits intoJun 16, 2026
Conversation
The early_end !null terminated minified test pops the last byte before its first read, so it never exercised the complete document. Add an explicit round-trip of the full buffer for the struct, glz::generic, and glz::skip readers, pinning that skip_ws's new end_reached return is cleared at depth 0 and does not regress valid input.
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.
In minified mode
skip_wsreturns right away without looking at the iterator, so it never runs theit == endcheck the non-minified branch does. With a non-null-terminated buffer (null_terminated = false) the JSON object, array, and tuple readers callskip_wsbetween tokens and then read*itto find the closing brace, bracket, or comma, so a truncated minified document that ends right after a member value reads one byte past the buffer. ASAN flags a heap-buffer-overflow in the object reader for input like{"c":[](no closing brace) parsed withglz::opts{.null_terminated = false, .minified = true}.Before, the minified branch of
skip_wswas a no-op for every option set. After, it runs the sameit == endtoend_reachedcheck the non-minified non-null-terminated branch already had, so every reader that leans onskip_wsto bound its next read stays inside the buffer. Putting the check inskip_wscovers the object, array, and tuple readers together instead of guarding each closing-token read separately, and the null-terminated path is untouched since it relies on the trailing sentinel.