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

Fuzz for compatibility with bincode v1#498

Merged
6 commits merged intotrunkfrom
unknown repository
Feb 7, 2022
Merged

Fuzz for compatibility with bincode v1#498
6 commits merged intotrunkfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Feb 2, 2022

This finds this input:

[20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252, 0, 0, 0, 0, 245]

Which fails because of

[fuzz_targets/roundtrip.rs:54] before = NonZeroU128(
    77990222474978957318644826112,
)
thread '<unnamed>' panicked at 'failed to deserialize: Custom("invalid value: integer `0`, expected a nonzero u128")', fuzz_targets/roundtrip.rs:55:17

Not sure if this is a bug, but making this as a draft to just make a note of it. I might want to move the compatibility check to a new fuzzer before this is merged.

@codecov
Copy link

codecov bot commented Feb 2, 2022

Codecov Report

Merging #498 (bbf842d) into trunk (2e16e13) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##            trunk     #498   +/-   ##
=======================================
  Coverage   69.09%   69.09%           
=======================================
  Files          44       44           
  Lines        3058     3058           
=======================================
  Hits         2113     2113           
  Misses        945      945           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e16e13...bbf842d. Read the comment docs.

fuzz_target!(|data: &[u8]| {
let config = bincode::config::standard().with_limit::<1024>();
let config = bincode::config::legacy().with_limit::<1024>();
let configv1 = bincodev1::DefaultOptions::new().with_limit(1024).allow_trailing_bytes();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will use varint encoding, the legacy() will use fixint. The true legacy config from bincode 1 is bincodev1::Config

@ghost
Copy link
Author

ghost commented Feb 5, 2022

Okay, this seems like it's correct? Unless I'm missing something else with the config (endian?).

Example output is

Bytes:      [7, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
Bincode V2: CString("")
Bincode V1: Err(Custom("nul byte found in provided data at position: 0"))

@ghost ghost marked this pull request as ready for review February 5, 2022 16:32
@ghost
Copy link

ghost commented Feb 6, 2022

That specific issue should now be fixed in trunk.

@ghost
Copy link
Author

ghost commented Feb 6, 2022

I'm getting

Bytes:      [12, 0, 0, 0, 0, 100, 0, 0, 0, 100]
Bincode V1: Ok(Ipv4Addr(0.100.0.0))
Bincode V2: Err(UnexpectedEnd)

now.

@VictorKoenders
Copy link
Contributor

Fixed some compatibility issues in #503 including Result, Ipv4Addr and Ipv6Addr

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll look at a fix for the ip addr bug. But this PR looks good. We can run the fuzzer for a while.

@ghost ghost merged commit 3127ff5 into bincode-org:trunk Feb 7, 2022
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant