Skip to content

Fix panic and add tests#310

Closed
ss-es wants to merge 9 commits into
ferrilab:mainfrom
EspressoSystems:main
Closed

Fix panic and add tests#310
ss-es wants to merge 9 commits into
ferrilab:mainfrom
EspressoSystems:main

Conversation

@ss-es

@ss-es ss-es commented Jun 11, 2026

Copy link
Copy Markdown

Fixes a panic in the Deserialize implementation and adds tests

ss-es and others added 9 commits June 2, 2026 17:52
Cover BitVec/BitBox deserialization of tampered bincode buffers where
head + bits exceeds the data capacity. The head + bits overflow cases
currently abort (set_len assert + Vec::from_raw_parts UB in Drop) and
fail until the deserializer validates head + bits against capacity.

Adds proptest dev-dependency for the capacity-invariant property test.
BitVec/BitBox deserialization checked only bits > capacity (Vec capacity,
head ignored), so a tampered head + bits exceeding the live buffer reached
set_len and aborted (assert + Vec::from_raw_parts UB in Drop). Validate
head + bits <= vec.len() * bits_of::<T>() and return BitSpanError::TooLong
otherwise. Un-ignores the four regression/property tests.
fuzz_mutated_valid_buffer overwrites random bytes of a valid buffer;
fuzz_arbitrary_bytes feeds raw bytes. Both assert deserialization never
panics. Verified over 200k cases each.
The error path built BitSpan::new(addr, head, bits).unwrap_err(); when
try_from_vec fails (bit-length exceeds REGION_MAX_BITS) but the deserialized
bits is small, BitSpan::new returns Ok and unwrap_err panics. Return
BitSpanError::TooLong(live) directly, where live is the overflowing length.
This reverts commit 46ac849.
@ss-es ss-es closed this Jun 11, 2026
@ss-es

ss-es commented Jun 11, 2026

Copy link
Copy Markdown
Author

closed for #311 (squashing the commits)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants