Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit 1b5c2ab

Browse files
VictorKoendersVictor Koenders
andauthored
Made the compat fuzzer ignore any LimitExceeded error (#515)
* Made the compat fuzzer ignore any LimitExceeded error * Switched from deserialize to deserialize_from Co-authored-by: Victor Koenders <[email protected]>
1 parent 7e9f043 commit 1b5c2ab

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

fuzz/Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fuzz/fuzz_targets/compat.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,25 @@ fuzz_target!(|data: &[u8]| {
4343
#[allow(deprecated)]
4444
let mut configv1 = bincodev1::config();
4545
configv1.limit(1024);
46-
let bincode_v1: Result<AllTypes, _> = configv1.deserialize(data);
46+
let bincode_v1: Result<AllTypes, _> = configv1.deserialize_from(data);
4747
let bincode_v2: Result<(AllTypes, _), _> = bincode::decode_from_slice(data, config);
4848

49-
if bincode_v1.as_ref().ok() != bincode_v2.as_ref().ok().map(|x| &x.0) {
50-
println!("Bytes: {:?}", data);
51-
println!("Bincode V1: {:?}", bincode_v1);
52-
println!("Bincode V2: {:?}", bincode_v2);
53-
panic!("failed equality check");
49+
match (&bincode_v1, &bincode_v2) {
50+
(Err(e), _) if e.to_string() == "the size limit has been reached" => {},
51+
(_, Err(bincode::error::DecodeError::LimitExceeded)) => {},
52+
(Ok(bincode_v1), Ok((bincode_v2, _))) if bincode_v1 != bincode_v2 => {
53+
println!("Bytes: {:?}", data);
54+
println!("Bincode V1: {:?}", bincode_v1);
55+
println!("Bincode V2: {:?}", bincode_v2);
56+
panic!("failed equality check");
57+
},
58+
(Ok(_), Err(_)) | (Err(_), Ok(_)) => {
59+
println!("Bytes: {:?}", data);
60+
println!("Bincode V1: {:?}", bincode_v1);
61+
println!("Bincode V2: {:?}", bincode_v2);
62+
panic!("failed equality check");
63+
}
64+
65+
_ => {}
5466
}
5567
});

0 commit comments

Comments
 (0)