Repository navigation
reject ext32 length 0xffffffff in the x3 parser - #1219
Merged
Merged
Conversation
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## cpp_master #1219 +/- ##
==============================================
- Coverage 85.36% 79.91% -5.46%
==============================================
Files 80 80
Lines 5099 5804 +705
Branches 507 634 +127
==============================================
+ Hits 4353 4638 +285
- Misses 746 1166 +420 🚀 New features to boost your workflow:
|
Contributor
|
@rajath201 , thank you for sending the PR. It looks good to me. |
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.
Repro: with
MSGPACK_USE_X3_PARSE,msgpack::unpack(first, last)on the 8 bytes92 c9 ff ff ff ff 01 02returns[EXT(ptr=NULL, size=0), 2]instead of failing; callingext.type()or streaming the object withoperator<<then dereferences the null ptr (segfault on clang 23, x64).Cause: the ext32 action in
x3_parse.hppcomputes the element count as_attr(ctx)+1in 32-bit unsigned arithmetic, so a declared length of 0xffffffff wraps to 0. The parser consumes neither the type byte nor the payload, and the bytes that belong to the 4 GiB body are parsed as sibling objects. That is a framing disagreement with the regular v1/v2/v3 parsers, which either wait for the full payload or throw viacheck_ext_size<4>. a78b895 widenedvisit_exttosize_tbut left this addition in 32 bits.Fix: widen to
size_tbefore adding one, and throwext_size_overflowwhensize_tcan't hold the result, the same checkcheck_ext_size<4>does inparse.hpp. On 64-bit the short input now fails as a parse error; on 32-bit it throwsext_size_overflow.ext32_max_size_truncatedfails on the current tree and passes with the fix; the rest ofmsgpack_x3_parse(64 cases) passes at 64 and 32 bit, with no new-Wall -Wextra -Wconversionwarnings.