Repository navigation
Reject numbers with no digits after a sign or 0x - #134
Merged
Merged
Conversation
A sign as the last byte of the input skipped the 'sign must be followed by a digit' check, and the hexadecimal branch accepted 0x with no digits.
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.
json_get_number_sizeaccepts a number with no digits in two places:-(or+withallow_leading_plus_sign) as the last byte of the input, because the "sign must be followed by a digit" check is guarded byoffset < size.json_parse("-", 1)succeeds, and with simplified JSONa = 1\nb = -is written back as{"a":1,"b":-}.0x,-0xand+0xwithallow_hexadecimal_numbers, because the hex loop accepts zero digits, so[0x]is read as0. JSON5 requires at least one hex digit.This checks
offset >= sizethe way the decimal point check below already does, and requires one hex digit after0x. The four new tests fail on main; 1737 pass with gcc Debug and under ASan+UBSan. I did not run clang, tcc or MSVC.Written with AI assistance (Claude); I have reviewed the change.