diff options
author | van Hauser <vh@thc.org> | 2021-03-01 10:12:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 10:12:04 +0100 |
commit | bd0a23de73011a390714b9f3836a46443054fdd5 (patch) | |
tree | 9b2335f357e84e18e4c8259581360923921ca8b2 /custom_mutators/rust/example/src | |
parent | 5cf0655071a83b1c87490be8399fe2365f087223 (diff) | |
parent | 4619a1395b9a414e5e11148d79fde3a7fa348e87 (diff) | |
download | afl++-bd0a23de73011a390714b9f3836a46443054fdd5.tar.gz |
Merge pull request #767 from AFLplusplus/dev 3.10c
Final push for release
Diffstat (limited to 'custom_mutators/rust/example/src')
-rw-r--r-- | custom_mutators/rust/example/src/example_mutator.rs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/custom_mutators/rust/example/src/example_mutator.rs b/custom_mutators/rust/example/src/example_mutator.rs new file mode 100644 index 00000000..9b9d4997 --- /dev/null +++ b/custom_mutators/rust/example/src/example_mutator.rs @@ -0,0 +1,49 @@ +#![allow(unused_variables)] + +use custom_mutator::{export_mutator, CustomMutator}; + +struct ExampleMutator; + +impl CustomMutator for ExampleMutator { + type Error = (); + + fn init(seed: u32) -> Result<Self, Self::Error> { + Ok(Self) + } + + fn fuzz<'b, 's: 'b>( + &'s mut self, + buffer: &'b mut [u8], + add_buff: Option<&[u8]>, + max_size: usize, + ) -> Result<Option<&'b [u8]>, Self::Error> { + buffer.reverse(); + Ok(Some(buffer)) + } +} + +struct OwnBufferExampleMutator { + own_buffer: Vec<u8>, +} + +impl CustomMutator for OwnBufferExampleMutator { + type Error = (); + + fn init(seed: u32) -> Result<Self, Self::Error> { + Ok(Self { + own_buffer: Vec::new(), + }) + } + + fn fuzz<'b, 's: 'b>( + &'s mut self, + buffer: &'b mut [u8], + add_buff: Option<&[u8]>, + max_size: usize, + ) -> Result<Option<&'b [u8]>, ()> { + self.own_buffer.reverse(); + Ok(Some(self.own_buffer.as_slice())) + } +} + +export_mutator!(ExampleMutator); |