guard eetf big integer sign byte read against end#2631
Merged
stephenberry merged 4 commits intoJun 16, 2026
Conversation
All callers maintain it <= end (every advance is bounds-checked or followed by invalid_end), so end - it is non-negative and the it > end disjunct can never fire. The subtraction keeps the overflow safety of avoiding (it + off) while matching the original check's instruction count.
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.
term_to_json_big_integer reads the sign byte of a SMALL_BIG term with
const int sign = *tit++, but get8s only validates and consumes the length byte that precedes it. A term that ends right after that length byte (the two bytes6e 00) leaves tit sitting at end, so the sign read runs one byte past the input buffer.Before, the size byte is range checked but the sign byte right after it is read unconditionally. After, the error from get8s is honored and check_invalid_offset gates the sign read, the same guard the string and atom cases in this file already use. Keeping the check next to the read makes a truncated term fail with unexpected_end rather than touching memory past the buffer; the cost is a single comparison on a path that was already doing per-field bounds checks.