account for completed utf-8 sequence in parse_string size limit - #1185
account for completed utf-8 sequence in parse_string size limit#1185Ramya-9353 wants to merge 3 commits into
Conversation
|
An automated preview of the documentation is available at https://1185.json.prtest2.cppalliance.org/libs/json/doc/html/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-08-13 06:54:42 UTC |
|
GCOVR code coverage report https://1185.json.prtest2.cppalliance.org/gcovr/index.html Build time: 2026-08-13 06:57:59 UTC |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1185 +/- ##
===========================================
- Coverage 93.92% 93.92% -0.01%
===========================================
Files 91 91
Lines 9290 9297 +7
===========================================
+ Hits 8726 8732 +6
- Misses 564 565 +1
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
|
|
|
|
So, coverage checks fail on this PR here: https://1185.json.prtest2.cppalliance.org/diff-report/include/boost/json/basic_parser_impl.hpp.html#NL1125 This shows that we do not have a test for when a key has a UTF-8 multibyte character, the parser suspends within it and then resumes. Can you please add a test for that as a separate commit, so that the PR's CI is green? |
|
Added in a separate commit: same feed shape as the key overflow test, but with string::max_size() - 2 filler bytes so the split character completes on the str8 resume path exactly at the limit and the key parses cleanly. That runs the on_key_part call the diff report flagged as uncovered. Passes locally under ASan/UBSan. |
|
|



Repro: feed a multi-byte UTF-8 string to
stream_parserone byte at a time, so each character completes across awrite_someboundary;max_string_size/max_key_sizeis not applied to it andon_string_part/on_key_partreport atotalthat omits those bytes.Cause: the
str8resume path inparse_string(completing a UTF-8 sequence split across a chunk) emitsseq_.length()bytes to the handler without bounds-checking them or adding them tototal.do_str1andparse_escapedboth account before their handler calls;str8was the gap.Fix: on the
str8path, checkseq_.length()against the remaining budget and add it tototalbefore emitting, matchingdo_str1.Regression test in
test/limits.cppdrives split multi-byte strings and keys throughstream_parsera byte at a time; the size limits are skipped before the change and enforced after.