Reject nested indefinite-length CBOR string chunks - #5325
Open
JosephDemarest wants to merge 1 commit into
Open
Conversation
Signed-off-by: Joseph.Demarest <joseph@demarest.dev>
nlohmann
requested changes
Jul 31, 2026
Comment on lines
+1031
to
+1032
| return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, | ||
| exception_message(input_format_t::cbor, concat("expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token), "string"), nullptr)); |
Owner
There was a problem hiding this comment.
This can yield confusing error messages like
expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x7F
Maybe we should rather have something like
concat("indefinite-length string is not allowed inside indefinite-length string; last byte: 0x", last_token)or just drop the or indefinite string type (0x7F).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #5317.
Validation
ctest --test-dir build17 -j 8 -LE "not_reproducible|git_required" --output-on-failure— 77/77 passed (Clang 20, C++17)test-cbor_cpp17andtest-regression2_cpp17targets — passedsingle_include/nlohmann/json.hpp— both inputs raisedparse_error.113at byte 2git diff --check— cleanChecklist