minor fixes

This commit is contained in:
Alwin Berger 2023-10-06 14:33:01 +02:00
parent 5648255542
commit aba83dfb6f
2 changed files with 12 additions and 8 deletions

View File

@ -118,10 +118,10 @@ where
let m = interrupt_offsets[0..num_interrupts].iter().any(|x| (curr.start_tick..curr.end_tick).contains(&(*x as u64))); let m = interrupt_offsets[0..num_interrupts].iter().any(|x| (curr.start_tick..curr.end_tick).contains(&(*x as u64)));
if m { if m {
marks.push((curr, i, 1)); marks.push((curr, i, 1));
// println!("1: {}",curr.current_task.task_name); // println!("1: {}",curr.current_task.0.task_name);
} else if last_m { } else if last_m {
marks.push((curr, i, 2)); marks.push((curr, i, 2));
// println!("2: {}",curr.current_task.task_name); // println!("2: {}",curr.current_task.0.task_name);
} else { } else {
marks.push((curr, i, 0)); marks.push((curr, i, 0));
} }

View File

@ -15,6 +15,7 @@ use libafl::state::HasCorpus;
use libafl::state::HasSolutions; use libafl::state::HasSolutions;
use libafl::state::HasRand; use libafl::state::HasRand;
use crate::worst::MaxExecsLenFavFactor; use crate::worst::MaxExecsLenFavFactor;
use crate::worst::MaxTimeFavFactor;
use libafl::schedulers::MinimizerScheduler; use libafl::schedulers::MinimizerScheduler;
use libafl_bolts::HasRefCnt; use libafl_bolts::HasRefCnt;
use libafl_bolts::AsSlice; use libafl_bolts::AsSlice;
@ -164,7 +165,7 @@ impl HasRefCnt for SysGraphMetadata {
libafl_bolts::impl_serdeany!(SysGraphMetadata); libafl_bolts::impl_serdeany!(SysGraphMetadata);
pub type GraphMaximizerCorpusScheduler<CS> = pub type GraphMaximizerCorpusScheduler<CS> =
MinimizerScheduler<CS, MaxExecsLenFavFactor<<CS as UsesState>::State>,SysGraphMetadata>; MinimizerScheduler<CS, MaxTimeFavFactor<<CS as UsesState>::State>,SysGraphMetadata>;
//============================= Graph Feedback //============================= Graph Feedback
@ -214,11 +215,10 @@ impl SysGraphFeedbackState
let mut trace : Vec<NodeIndex> = vec![current_index]; let mut trace : Vec<NodeIndex> = vec![current_index];
for n in list { for n in list {
let mut matching : Option<NodeIndex> = None; let mut matching : Option<NodeIndex> = None;
for i in self.graph.neighbors_directed(current_index, Direction::Outgoing) { for i in self.graph.node_indices() {
let tmp = &self.graph[i]; let tmp = &self.graph[i];
if n == &tmp.base { if n == &tmp.base {
matching = Some(i); matching = Some(i);
current_index = i;
break; break;
} }
} }
@ -226,16 +226,20 @@ impl SysGraphFeedbackState
None => { None => {
novel = true; novel = true;
let j = self.graph.add_node(SysGraphNode::from(n.clone(),input.clone())); let j = self.graph.add_node(SysGraphNode::from(n.clone(),input.clone()));
self.graph.add_edge(current_index, j, ()); self.graph.update_edge(current_index, j, ());
current_index = j; current_index = j;
}, },
Some(i) => { Some(i) => {
novel |= self.graph[i].unite_interesting(&n, input); novel |= self.graph[i].unite_interesting(&n, input);
self.graph.update_edge(current_index, i, ());
current_index = i;
} }
} }
trace.push(current_index); trace.push(current_index);
} }
if current_index != self.entrypoint {
self.graph.update_edge(current_index, self.exit, ()); // every path ends in the exit noded self.graph.update_edge(current_index, self.exit, ()); // every path ends in the exit noded
}
return (novel, trace); return (novel, trace);
} }
} }
@ -315,7 +319,7 @@ where
/// Append to the testcase the generated metadata in case of a new corpus item /// Append to the testcase the generated metadata in case of a new corpus item
#[inline] #[inline]
fn append_metadata<OT>(&mut self, _state: &mut S, observers: &OT, testcase: &mut Testcase<S::Input>) -> Result<(), Error> { fn append_metadata<OT>(&mut self, _state: &mut S, _observers: &OT, testcase: &mut Testcase<S::Input>) -> Result<(), Error> {
let a = self.last_trace.take(); let a = self.last_trace.take();
match a { match a {
Some(s) => testcase.metadata_map_mut().insert(SysGraphMetadata::new(s)), Some(s) => testcase.metadata_map_mut().insert(SysGraphMetadata::new(s)),