fix: throw when MessagePack size exceeds uint32 limit (#5320) - #5381
Open
ameliabarnabyhub wants to merge 2 commits into
Open
fix: throw when MessagePack size exceeds uint32 limit (#5320)#5381ameliabarnabyhub wants to merge 2 commits into
ameliabarnabyhub wants to merge 2 commits into
Conversation
Signed-off-by: ameliabarnabyhub <ameliabarnabyhub@users.noreply.github.com>
Signed-off-by: ameliabarnabyhub <ameliabarnabyhub@users.noreply.github.com>
gregmarr
reviewed
Aug 13, 2026
| */ | ||
| void assert_msgpack_size(const std::size_t size, const BasicJsonType* const context = nullptr) const | ||
| { | ||
| if (JSON_HEDLEY_UNLIKELY(!value_in_range_of<std::uint32_t>(size))) |
Contributor
There was a problem hiding this comment.
Why do you need this test when this is only called when this is known to be true?
gregmarr
reviewed
Aug 13, 2026
| /*! | ||
| @throw out_of_range.412 if @a size exceeds the MessagePack uint32 length limit | ||
| */ | ||
| void assert_msgpack_size(const std::size_t size, const BasicJsonType* const context = nullptr) const |
Contributor
There was a problem hiding this comment.
Since this is always passed a pointer, don't need the default argument.
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated and/or formatted correctly. 📎 A ready-to-apply patch is attached to the failed workflow run as the git apply amalgamation.patchThis does not require installing astyle yourself. |
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.
Fixes #5320
to_msgpack()now throwsout_of_range.412when a string, array, binary, or object reports a size aboveUINT32_MAX, matching the documented MessagePack limit and the BSON fix pattern from #5314.Adds a regression test using a container type that reports an oversized
size()without allocating multi-gigabyte data.