buffer_skip_whitespace accepts every byte below 0x21 as whitespace
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- c
- Domain
- backend-api-design
Research direction
Start at the buffer_skip_whitespace loop reached through cJSON_ParseWithLengthOpts and inspect how bytes below 0x21 are classified. Restrict whitespace handling to space, tab, LF, and CR, then verify that the shown control-byte inputs are rejected while valid JSON whitespace remains accepted.
Written by the indexing model from the issue text.
Description
buffer_skip_whitespace skips any byte <= 32, so NUL, 0x01, 0x0b, 0x1f, and every other control byte are accepted as whitespace between tokens. JSON whitespace is only space, tab, LF, and CR. With cJSON_ParseWithLengthOpts the NUL case is reachable too:
cJSON_ParseWithLengthOpts("[\x0b1]", 5, NULL, 1); /* [1] */
cJSON_ParseWithLengthOpts("[\x011]", 5, NULL, 1); /* [1] */
cJSON_ParseWithLengthOpts("\x00null", 6, NULL, 1); /* null */
Form feed is in the JSONTestSuite list in #877 and control characters inside strings are #871; the other bytes between tokens are not in either. Found on v1.7.19 with a property that splices one control byte at a random offset of a valid document. A fix is to accept only ' ', '\t', '\n', '\r' in that loop.
- Dominant language
- C
- Stars
- 13k
- Forks
- 3.5k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DaveGamble/cJSON
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
DaveGamble/cJSON#1082 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
DaveGamble/cJSON#1081 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
DaveGamble/cJSON#1071 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DaveGamble/cJSON#1067 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
DaveGamble/cJSON#1050 · 1 comment ·
All issues in DaveGamble/cJSON
Similar issues
-
level/task module/gcp type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
hapostgres/pg_auto_failover#1190 ·
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
P3 sonic-vpp
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sonic-net/sonic-buildimage#29662 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
spack/spack-packages#6586 ·