prevent MAX_STG_NUM out of bounds
This commit is contained in:
parent
d2fe86f867
commit
083adc7e38
@ -12,6 +12,7 @@ use libafl::prelude::State;
|
|||||||
use libafl::schedulers::MinimizerScheduler;
|
use libafl::schedulers::MinimizerScheduler;
|
||||||
use libafl_bolts::HasRefCnt;
|
use libafl_bolts::HasRefCnt;
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
|
use std::cmp::min;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use libafl::corpus::Testcase;
|
use libafl::corpus::Testcase;
|
||||||
@ -381,7 +382,7 @@ where
|
|||||||
|
|
||||||
//============================= Graph Feedback
|
//============================= Graph Feedback
|
||||||
|
|
||||||
pub const STG_MAP_SIZE: usize = 1<<28; // 512MB
|
pub const STG_MAP_SIZE: usize = 1<<29; // 1024 MB
|
||||||
pub static mut STG_MAP: [u16; STG_MAP_SIZE] = [0; STG_MAP_SIZE];
|
pub static mut STG_MAP: [u16; STG_MAP_SIZE] = [0; STG_MAP_SIZE];
|
||||||
pub static mut MAX_STG_NUM: usize = 0;
|
pub static mut MAX_STG_NUM: usize = 0;
|
||||||
pub unsafe fn stg_map_mut_slice<'a>() -> OwnedMutSlice<'a, u16> {
|
pub unsafe fn stg_map_mut_slice<'a>() -> OwnedMutSlice<'a, u16> {
|
||||||
@ -450,10 +451,10 @@ fn set_observer_map(trace : &Vec<EdgeIndex>) {
|
|||||||
STG_MAP[i] = 0;
|
STG_MAP[i] = 0;
|
||||||
}
|
}
|
||||||
for i in trace {
|
for i in trace {
|
||||||
if MAX_STG_NUM < i.index() {
|
|
||||||
MAX_STG_NUM = i.index();
|
|
||||||
}
|
|
||||||
if i.index() < STG_MAP.len() {
|
if i.index() < STG_MAP.len() {
|
||||||
|
if MAX_STG_NUM < i.index() {
|
||||||
|
MAX_STG_NUM = min(i.index(), STG_MAP.len() - 1);
|
||||||
|
}
|
||||||
STG_MAP[i.index()] = STG_MAP[i.index()].saturating_add(1);
|
STG_MAP[i.index()] = STG_MAP[i.index()].saturating_add(1);
|
||||||
} else {
|
} else {
|
||||||
eprintln!("STG Map index out of bounds: {}", i.index());
|
eprintln!("STG Map index out of bounds: {}", i.index());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user