aboutsummaryrefslogtreecommitdiff
path: root/custom_mutators
diff options
context:
space:
mode:
authorDominik Maier <domenukk@gmail.com>2021-07-21 02:00:15 +0200
committerDominik Maier <domenukk@gmail.com>2021-07-21 02:00:15 +0200
commit3d7a2fc869a03da4c49a0a7e05d97f01a2846337 (patch)
tree1a0db27d50050972cf7050a549af03634f831738 /custom_mutators
parenta3a86afd0db5bf90d6bc1dc5f58d07e6bc7202c8 (diff)
downloadAFLplusplus-3d7a2fc869a03da4c49a0a7e05d97f01a2846337.tar.gz
fixed rust example
Diffstat (limited to 'custom_mutators')
m---------custom_mutators/grammar_mutator/grammar_mutator0
-rw-r--r--custom_mutators/rust/custom_mutator/src/lib.rs42
2 files changed, 23 insertions, 19 deletions
diff --git a/custom_mutators/grammar_mutator/grammar_mutator b/custom_mutators/grammar_mutator/grammar_mutator
-Subproject b79d51a8daccbd7a693f9b6765c81ead14f28e2
+Subproject b3c4fcfa6ae28918bc410f7747135eafd4fb726
diff --git a/custom_mutators/rust/custom_mutator/src/lib.rs b/custom_mutators/rust/custom_mutator/src/lib.rs
index 39c2b453..013d3769 100644
--- a/custom_mutators/rust/custom_mutator/src/lib.rs
+++ b/custom_mutators/rust/custom_mutator/src/lib.rs
@@ -226,6 +226,10 @@ pub mod wrappers {
}
/// Internal function used in the macro
+ ///
+ /// # Safety
+ /// Dereferences the passed-in pointers up to `buf_size` bytes.
+ /// Should not be called directly.
pub unsafe fn afl_custom_fuzz_count_<M: RawCustomMutator>(
data: *mut c_void,
buf: *const u8,
@@ -278,6 +282,10 @@ pub mod wrappers {
}
/// Internal function used in the macro
+ ///
+ /// # Safety
+ /// May dereference the passed-in `data` pointer.
+ /// Should not be called directly.
pub unsafe fn afl_custom_deinit_<M: RawCustomMutator>(data: *mut c_void) {
match catch_unwind(|| {
// drop the context
@@ -392,18 +400,16 @@ macro_rules! export_mutator {
}
#[no_mangle]
- pub extern "C" fn afl_custom_fuzz_count(
+ pub unsafe extern "C" fn afl_custom_fuzz_count(
data: *mut ::std::os::raw::c_void,
buf: *const u8,
buf_size: usize,
) -> u32 {
- unsafe {
- $crate::wrappers::afl_custom_fuzz_count_::<$mutator_type>(data, buf, buf_size)
- }
+ $crate::wrappers::afl_custom_fuzz_count_::<$mutator_type>(data, buf, buf_size)
}
#[no_mangle]
- pub extern "C" fn afl_custom_fuzz(
+ pub unsafe extern "C" fn afl_custom_fuzz(
data: *mut ::std::os::raw::c_void,
buf: *mut u8,
buf_size: usize,
@@ -412,17 +418,15 @@ macro_rules! export_mutator {
add_buf_size: usize,
max_size: usize,
) -> usize {
- unsafe {
- $crate::wrappers::afl_custom_fuzz_::<$mutator_type>(
- data,
- buf,
- buf_size,
- out_buf,
- add_buf,
- add_buf_size,
- max_size,
- )
- }
+ $crate::wrappers::afl_custom_fuzz_::<$mutator_type>(
+ data,
+ buf,
+ buf_size,
+ out_buf,
+ add_buf,
+ add_buf_size,
+ max_size,
+ )
}
#[no_mangle]
@@ -430,7 +434,7 @@ macro_rules! export_mutator {
data: *mut ::std::os::raw::c_void,
filename_new_queue: *const ::std::os::raw::c_char,
filename_orig_queue: *const ::std::os::raw::c_char,
- ) {
+ ) -> bool {
$crate::wrappers::afl_custom_queue_new_entry_::<$mutator_type>(
data,
filename_new_queue,
@@ -462,8 +466,8 @@ macro_rules! export_mutator {
}
#[no_mangle]
- pub extern "C" fn afl_custom_deinit(data: *mut ::std::os::raw::c_void) {
- unsafe { $crate::wrappers::afl_custom_deinit_::<$mutator_type>(data) }
+ pub unsafe extern "C" fn afl_custom_deinit(data: *mut ::std::os::raw::c_void) {
+ $crate::wrappers::afl_custom_deinit_::<$mutator_type>(data)
}
};
}