From 253c6b5bdc2e05ecff687eea630849dc45a956d4 Mon Sep 17 00:00:00 2001 From: syheliel <45957390+syheliel@users.noreply.github.com> Date: Fri, 8 Jul 2022 15:45:56 +0800 Subject: [PATCH] Use SHMEM_FUZZ_HDR_SIZE constant (#695) * Fix misuse of SHMEM_FUZZ_HDR_SIZE * fix `cargo fmt` Co-authored-by: syheliel --- libafl/src/executors/forkserver.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libafl/src/executors/forkserver.rs b/libafl/src/executors/forkserver.rs index 2651008d8e..a3d9fdedc8 100644 --- a/libafl/src/executors/forkserver.rs +++ b/libafl/src/executors/forkserver.rs @@ -44,6 +44,7 @@ const FS_OPT_ENABLED: i32 = 0x80000001_u32 as i32; const FS_OPT_SHDMEM_FUZZ: i32 = 0x01000000_u32 as i32; #[allow(clippy::cast_possible_wrap)] const FS_OPT_AUTODICT: i32 = 0x10000000_u32 as i32; +/// The length of header bytes which tells shmem size const SHMEM_FUZZ_HDR_SIZE: usize = 4; const MAX_FILE: usize = 1024 * 1024; @@ -870,7 +871,8 @@ where let size = target_bytes.as_slice().len(); let size_in_bytes = size.to_ne_bytes(); // The first four bytes tells the size of the shmem. - map.as_mut_slice()[..4].copy_from_slice(&size_in_bytes[..4]); + map.as_mut_slice()[..SHMEM_FUZZ_HDR_SIZE] + .copy_from_slice(&size_in_bytes[..SHMEM_FUZZ_HDR_SIZE]); map.as_mut_slice()[SHMEM_FUZZ_HDR_SIZE..(SHMEM_FUZZ_HDR_SIZE + size)] .copy_from_slice(target_bytes.as_slice()); }