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

deserialize_from silently ignore reject_trailing_bytes #732

Open
behzadnouri opened this issue Nov 20, 2024 · 2 comments
Open

deserialize_from silently ignore reject_trailing_bytes #732

behzadnouri opened this issue Nov 20, 2024 · 2 comments

Comments

@behzadnouri
Copy link

behzadnouri commented Nov 20, 2024

Edit: this happens on v1.3.3.

Below I am using reject_trailing_bytes and de-serializing a u64 from [0u8; 10].
So I am expecting to get an error, however bincode silently ignores reject_trailing_bytes and returns no error even though the cursor is not at the end yet.

#[test]
fn test_bincode_reject_trailing_bytes() {
    let bytes = [0u8; 10];
    let mut cursor = std::io::Cursor::new(bytes);
    let out = bincode::options()
        .with_fixint_encoding()
        .reject_trailing_bytes()
        .deserialize_from::<_, u64>(&mut cursor);
    assert_eq!(cursor.position(), 8);
    assert_matches!(out, Err(_));
}
@VictorKoenders
Copy link
Contributor

What version of bincode are you using?

@behzadnouri
Copy link
Author

What version of bincode are you using?

bincode v1.3.3

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

No branches or pull requests

2 participants