Repository navigation
widen the ext allocation size in object_with_zone<type::ext> - #1230
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## cpp_master #1230 +/- ##
==============================================
- Coverage 85.36% 80.03% -5.34%
==============================================
Files 80 80
Lines 5099 5830 +731
Branches 507 645 +138
==============================================
+ Hits 4353 4666 +313
- Misses 746 1164 +418 🚀 New features to boost your workflow:
|
|
Verified on a 64 GiB machine with a real 0xffffffff-byte ext: before the patch, While checking I noticed the same |
Targets cpp_master.
object_with_zone<msgpack::type::ext>ininclude/msgpack/v1/adaptor/ext.hppsizes the zone copy assize + 1with auint32_tsize, butmsgpack::type::extaccepts a 0xffffffff-byte payload on 64-bit targets, so for the spec-maximum ext32 the sum wraps to 0 and theptr[0]store plusmemcpy(ptr + 1, v.data(), size)write 4 GiB past a zero-byte zone slot. Unpackingc9 ff ff ff ff 01+ 4 GiB with anunpack_limitthat admits the maximum ext (the default 0xffffffff ext limit counts the type byte and rejects it), thenas<msgpack::type::ext>()andmsgpack::object(e, zone), gives an ASan heap-buffer-overflow WRITE of size 4294967295 at ext.hpp:110 into the zone's 8200-byte initial chunk.Widen to
std::size_tbefore adding the type byte, which is whatobject_with_zone<msgpack::object>already does through itssize_tvisit_ext; 32-bit builds are unaffected since the ext constructor caps payloads at 0xfffffffe there. It is the same wrap as #1219, but in the adaptor instead of the X3 parser, and here it corrupts the heap. I left out a committed test because reaching it needs about 8 GiB of live allocations; with the fix the reproducer completes with the payload intact, and object_with_zone, msgpack_basic, boost_variant and object pass under ASan.