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

Dynamic deserialization proposal #861

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion libafl/src/inputs/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ mod test {

use crate::{
bolts::AsSlice,
inputs::{BytesInput, GeneralizedInput, HasTargetBytes, Input},
inputs::{BytesInput, GeneralizedInput, HasTargetBytes, Input, NopInput},
};

#[test]
Expand All @@ -146,4 +146,15 @@ mod test {
let bytes = BytesInput::deserialize_dynamic(&buf).unwrap().unwrap();
assert_eq!(bytes.target_bytes().as_slice(), b"hello");
}

#[test]
fn failed_deserialize_from_nop() {
// note that NopInput implements HasTargetBytes, but because we have not submitted the
// conversion BytesInput cannot be converted from NopInput

let nop = NopInput {};
let mut buf = Vec::new();
nop.serialize_dynamic(&mut buf).unwrap();
assert!(BytesInput::deserialize_dynamic(&buf).unwrap().is_none());
}
Comment on lines +152 to +160
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See comments here: if the deserialisation for this type cannot occur, it is skipped and not deserialised.

}