Skip to content

Limit numeric token length during parsing#1030

Open
RolandK wants to merge 1 commit into
DaveGamble:masterfrom
RolandK:parse_number_size_limit
Open

Limit numeric token length during parsing#1030
RolandK wants to merge 1 commit into
DaveGamble:masterfrom
RolandK:parse_number_size_limit

Conversation

@RolandK
Copy link
Copy Markdown

@RolandK RolandK commented Jun 3, 2026

parse_number() copies the numeric token into a temporary null-terminated buffer before passing it to strtod(). Currently, the token length is bounded only by the remaining input size, so unusually long numeric tokens can lead to
large temporary allocations.

This change rejects numeric tokens longer than CJSON_NUMBER_LENGTH_LIMIT before allocating the temporary number string.

@RolandK RolandK force-pushed the parse_number_size_limit branch from fcef41a to 92395c0 Compare June 3, 2026 13:41
Reject overly long numeric tokens before allocating temporary number
strings to avoid unbounded allocations for malformed or malicious JSON
input.
@RolandK RolandK force-pushed the parse_number_size_limit branch from 92395c0 to 77e4743 Compare June 3, 2026 13:43
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