Repository navigation
Conversation
parse_hex4 returned 0 for a non-hex digit, so utf16_literal_to_utf8 decoded a malformed escape such as \uX000 as U+0000 and the string was silently truncated there. Report the failure separately and reject the escape. Fixes DaveGamble#635
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.
parse_hex4 returns 0 when it hits a non-hex digit, and utf16_literal_to_utf8 cannot tell that apart from a literal \u0000, so any malformed escape like \uX000 or \u00G1 is accepted and decoded as U+0000. Since valuestring is NUL-terminated the value is silently cut off there: {"role":"admin\uZZZZ-guest"} parses fine with role set to "admin", while conforming parsers reject the document. parse_hex4 now reports the failure separately from the value and both halves of a surrogate pair are checked; tests for the invalid cases are added to parse_hex4.c and parse_string.c (the existing parse_hex4 tests are adjusted for the new signature).
Fixes #635