Skip to content

guard eetf big integer sign byte read against end#2631

Merged
stephenberry merged 4 commits into
stephenberry:mainfrom
uwezkhan:eetf-bigint-sign-bounds
Jun 16, 2026
Merged

guard eetf big integer sign byte read against end#2631
stephenberry merged 4 commits into
stephenberry:mainfrom
uwezkhan:eetf-bigint-sign-bounds

Conversation

@uwezkhan

Copy link
Copy Markdown
Contributor

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 bytes 6e 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.

uwezkhan and others added 4 commits June 16, 2026 11:42
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.
@stephenberry stephenberry merged commit 907130f into stephenberry:main Jun 16, 2026
52 of 53 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.

2 participants