Skip to content

Keep unsigned jsonb integers above i64::MAX - #5197

Draft
LucaCappelletti94 wants to merge 1 commit into
diesel-rs:mainfrom
LucaCappelletti94:fuzz-sqlite-jsonb-unsigned-writer
Draft

Keep unsigned jsonb integers above i64::MAX#5197
LucaCappelletti94 wants to merge 1 commit into
diesel-rs:mainfrom
LucaCappelletti94:fuzz-sqlite-jsonb-unsigned-writer

Conversation

@LucaCappelletti94

@LucaCappelletti94 LucaCappelletti94 commented Sep 4, 2026

Copy link
Copy Markdown
Member

write_jsonb_number no longer rounds a u64 past i64::MAX, since #5195 replaced that code, but its new classifier treats any character that is not an ASCII digit as float syntax, and a minus sign is one, so json!(-1) is now written as a FLOAT that json_valid rejects and diesel cannot read back. This recognizes integer text instead, an optional minus followed by digits.

With the unsigned value now an exact INT, read_jsonb_int turned out to reject it, having kept a payload only when it parsed as an i64, so jsonb('18446744073709551615') did not read back either. It now accepts any integer payload that survives without rounding.

This came out of a fuzzer I am writing for diesel's deserialization code, and this PR only adds the red test for now.

@weiznich

weiznich commented Sep 4, 2026

Copy link
Copy Markdown
Member

Just to note this down here: This likely affects i128 and u128 as well. The fix done in #5195 should address this specific case and also the larger integers as well

@LucaCappelletti94
LucaCappelletti94 force-pushed the fuzz-sqlite-jsonb-unsigned-writer branch 3 times, most recently from d0dba79 to 22e8ba1 Compare September 5, 2026 06:46
@LucaCappelletti94
LucaCappelletti94 force-pushed the fuzz-sqlite-jsonb-unsigned-writer branch from 22e8ba1 to e598639 Compare September 5, 2026 07:21
@weiznich
weiznich requested review from a team and a lite review from Copilot and removed request for Copilot September 5, 2026 09:44
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