You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make typed-array length checks overflow-safe (BEVE, CBOR)
BEVE typed-array bounds checks computed it + count * element_size > end
(or end - it < count * element_size), where count comes from the wire.
On the 32-bit targets the project builds (armv7, gcc-x86) that product
overflows size_t and wraps small, so an oversized typed array slips past
the check and a later read/copy/span runs off the buffer; the additive
form is also out-of-bounds pointer arithmetic.
Route all ten BEVE sites (read, skip, beve_to_json) through a new
typed_array_out_of_bounds helper. On 32-bit it tests the fit as
count > (remaining - padding) / element_size, a division that cannot
overflow. On 64-bit, where int_from_compressed already caps counts at
2^48 (so the product is <= ~2^55 and cannot overflow), an if constexpr
selects the existing single multiply + compare against end - it, leaving
64-bit codegen unchanged (verified identical assembly).
CBOR map validation used count * 2 > end - it where count comes from an
unclamped decode_arg, so the product overflows uint64_t on every platform
for count >= 2^63; rewrite as count > (end - it) / 2.
0 commit comments