Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuzz for compatibility with bincode v1 #498

Merged
merged 6 commits into from
Feb 7, 2022
Merged

Conversation

5225225
Copy link
Contributor

@5225225 5225225 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.

@@ -40,12 +38,22 @@ enum AllTypes {
}

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
Collaborator

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

@5225225
Copy link
Contributor Author

5225225 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"))

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

ZoeyR commented Feb 6, 2022

That specific issue should now be fixed in trunk.

fuzz/fuzz_targets/compat.rs Outdated Show resolved Hide resolved
@5225225
Copy link
Contributor Author

5225225 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
Collaborator

@ZoeyR ZoeyR 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.

@ZoeyR ZoeyR merged commit 3127ff5 into bincode-org:trunk Feb 7, 2022
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.

3 participants