Skip to content

Fix parsing of exact-length JSON with a UTF-8 BOM - #1077

Open
Sn0wyDay wants to merge 1 commit into
DaveGamble:masterfrom
Sn0wyDay:fix-exact-length-utf8-bom
Open

Fix parsing of exact-length JSON with a UTF-8 BOM#1077
Sn0wyDay wants to merge 1 commit into
DaveGamble:masterfrom
Sn0wyDay:fix-exact-length-utf8-bom

Conversation

@Sn0wyDay

Copy link
Copy Markdown

cJSON_ParseWithLength() rejects a valid four-byte, non-NUL-terminated
buffer containing a UTF-8 BOM followed by 0 (EF BB BF 30).

skip_utf8_bom() currently requires index 4 to be accessible before it
compares the three-byte BOM. This changes the bound to index 2, the last byte
read by strncmp(), and adds an exact-length regression test.

Validation:

  • The regression test fails before the source change and passes afterward.
  • The complete CTest suite passes 22/22 with ASan and UBSan enabled.
  • git diff --check passes.

@Sn0wyDay
Sn0wyDay force-pushed the fix-exact-length-utf8-bom branch from faddc35 to 5eac121 Compare September 12, 2026 17:06
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