Fix Generator (#2627)

* no min but max

* import

* large stack arrays ?
This commit is contained in:
Dongjia "toka" Zhang 2024-10-21 16:27:25 +02:00 committed by GitHub
parent fda1596ee2
commit f0da4d15da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -8,7 +8,7 @@ use libafl_bolts::rands::Rand;
use crate::{inputs::bytes::BytesInput, nonzero, state::HasRand, Error}; use crate::{inputs::bytes::BytesInput, nonzero, state::HasRand, Error};
pub mod gramatron; pub mod gramatron;
use core::cmp::min; use core::cmp::max;
pub use gramatron::*; pub use gramatron::*;
@ -83,7 +83,7 @@ where
{ {
fn generate(&mut self, state: &mut S) -> Result<BytesInput, Error> { fn generate(&mut self, state: &mut S) -> Result<BytesInput, Error> {
let mut size = state.rand_mut().below(self.max_size); let mut size = state.rand_mut().below(self.max_size);
size = min(size, 1); size = max(size, 1);
let random_bytes: Vec<u8> = (0..size) let random_bytes: Vec<u8> = (0..size)
.map(|_| state.rand_mut().below(nonzero!(256)) as u8) .map(|_| state.rand_mut().below(nonzero!(256)) as u8)
.collect(); .collect();
@ -111,7 +111,7 @@ where
{ {
fn generate(&mut self, state: &mut S) -> Result<BytesInput, Error> { fn generate(&mut self, state: &mut S) -> Result<BytesInput, Error> {
let mut size = state.rand_mut().below(self.max_size); let mut size = state.rand_mut().below(self.max_size);
size = min(size, 1); size = max(size, 1);
let printables = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz \t\n!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~".as_bytes(); let printables = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz \t\n!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~".as_bytes();
let random_bytes: Vec<u8> = (0..size) let random_bytes: Vec<u8> = (0..size)
.map(|_| *state.rand_mut().choose(printables).unwrap()) .map(|_| *state.rand_mut().choose(printables).unwrap())

View File

@ -62,6 +62,7 @@ impl FridaRuntime for CoverageRuntime {
impl CoverageRuntime { impl CoverageRuntime {
/// Create a new coverage runtime /// Create a new coverage runtime
#[must_use] #[must_use]
#[allow(clippy::large_stack_arrays)]
pub fn new() -> Self { pub fn new() -> Self {
Self(Rc::pin(RefCell::new(CoverageRuntimeInner { Self(Rc::pin(RefCell::new(CoverageRuntimeInner {
map: [0_u8; MAP_SIZE], map: [0_u8; MAP_SIZE],