diff --git a/fuzz/fuzzers/roundtrip_no_pad.rs b/fuzz/fuzzers/roundtrip_no_pad.rs index 23cff9e..813fcf6 100644 --- a/fuzz/fuzzers/roundtrip_no_pad.rs +++ b/fuzz/fuzzers/roundtrip_no_pad.rs @@ -1,11 +1,14 @@ #![no_main] -#[macro_use] extern crate libfuzzer_sys; +#[macro_use] +extern crate libfuzzer_sys; extern crate base64; use base64::engine::fast_portable; fuzz_target!(|data: &[u8]| { - let config = fast_portable::FastPortableConfig::new().with_encode_padding(false); + let config = fast_portable::FastPortableConfig::new() + .with_encode_padding(false) + .with_decode_padding_mode(fast_portable::DecodePaddingMode::RequireNone); let engine = fast_portable::FastPortable::from(&base64::alphabet::STANDARD, config); let encoded = base64::encode_engine(&data, &engine); diff --git a/fuzz/fuzzers/utils.rs b/fuzz/fuzzers/utils.rs index c1d7edf..0e7e190 100644 --- a/fuzz/fuzzers/utils.rs +++ b/fuzz/fuzzers/utils.rs @@ -22,9 +22,16 @@ pub fn random_engine(data: &[u8]) -> fast_portable::FastPortable { alphabet::STANDARD }; + let encode_padding = rng.gen(); + let decode_padding = if encode_padding { + fast_portable::DecodePaddingMode::RequireCanonical + } else { + fast_portable::DecodePaddingMode::RequireNone + }; let config = fast_portable::FastPortableConfig::new() - .with_encode_padding(rng.gen()) - .with_decode_allow_trailing_bits(rng.gen()); + .with_encode_padding(encode_padding) + .with_decode_allow_trailing_bits(rng.gen()) + .with_decode_padding_mode(decode_padding); fast_portable::FastPortable::from(&alphabet, config) }