fix: validate compact JSONB number continuations - #7822
Open
DarrenChangJR wants to merge 2 commits into
Open
Conversation
wenshao
requested changes
Aug 24, 2026
wenshao
left a comment
Member
There was a problem hiding this comment.
Not explored to full depth (tool budget reached): "agent 3b": 无**(所有计划内的核查均已完成)。.
中文说明
未探索到全部深度(达到工具调用预算):"agent 3b":无**(所有计划内的核查均已完成)。。
— qwen3.8-max via Qwen Code /review (v0.22.0)
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.
What this PR does and why
Compact JSONB integer and long encodings require one continuation byte after
their marker. When that byte is missing,
getIntByteandgetLongBytereadpast the reader's logical end.
This affects more than untyped parsing:
38andd0leakArrayIndexOutOfBoundsExceptionthrough 15 facade anddirect number-reader paths each;
same unchecked helpers;
{marker, 1}reads outside the slice andreturns integer
1.This change adds the logical-end check at the two shared helper boundaries.
Malformed inputs now consistently throw
JSONException, while all callersretain their existing offset handling. The already guarded three-byte compact
forms and valid encodings are unchanged.
Tests
boxed, number, big-number, float, and double readers;
Exact upstream searches on 2026-08-22 found no active duplicate. Closed #3883
is about malformed text JSON, while closed #7669 / PR #7696 handles declared
BC_BIGINTlengths rather than truncated compact-number encodings.中文说明
修改内容和原因
JSONB 的紧凑 int/long 编码在类型 marker 后还需要一个 continuation byte。该字节
缺失时,
getIntByte和getLongByte会越过 reader 的逻辑结束位置读取数据。影响不只是在无类型解析中抛错:
38和d0在各 15 条 facade/direct number-reader 路径中都会泄漏ArrayIndexOutOfBoundsException;并返回整数 1。
本修改在两个共享 helper 中按 reader 的逻辑
end统一检查边界。畸形输入现在稳定抛出
JSONException,所有调用方原有的 offset 处理保持不变。原本已有边界保护的三字节紧凑编码和合法输入均不受影响。
回归测试覆盖 int32/int64 marker 的 parse、typed facade、any、primitive、boxed、
number、big-number、float、double 路径,array/string length,array/object 内嵌值,
带有范围外 backing byte 的 slice,三字节截断对照,以及合法紧凑边界值。JSONB
focused group 104 项和 clean full core 7,981 项测试全部通过,无 failure、error、
skip 或 dump。2026-08-22 的精确上游检索没有发现 active duplicate;#3883 和
#7669 / #7696 是不同根因。