Skip to content

reject numbers that are not valid JSON in parse_number - #1108

Open
nabhan06 wants to merge 1 commit into
DaveGamble:masterfrom
nabhan06:json-number-grammar
Open

nabhan06 wants to merge 1 commit into
DaveGamble:masterfrom
nabhan06:json-number-grammar

Conversation

@nabhan06

Copy link
Copy Markdown

parse_number copies any run of [0-9+-.eE] into a temporary buffer and accepts whatever prefix strtod manages to convert, so [01], [-01], [00], [1.], [-.5], [2.e3] and [0.e1] all parse, even through cJSON_ParseWithOpts with require_null_terminated set. These are the n_number_* JSONTestSuite cases from #877, and they leave cJSON accepting documents that RFC 8259 parsers reject (0123 is read as decimal 123, where a lenient consumer may read it as octal). The token is now checked against the RFC 8259 number grammar before it reaches strtod, and the rejected forms are added to tests/parse_number.c.

parse_number passed any run of [0-9+-.eE] to strtod, so tokens such as
01, -01, 1., -.5 and 2.e3 were accepted even with
require_null_terminated. Check the token against the RFC 8259 number
grammar before converting it.
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.

1 participant