fix mutations
This commit is contained in:
parent
e78fbc0f0f
commit
27cc1d8af6
@ -270,10 +270,10 @@ where
|
|||||||
I: Input + HasBytesVec,
|
I: Input + HasBytesVec,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
{
|
{
|
||||||
if input.bytes().len() <= 1 {
|
if input.bytes().len() == 0 {
|
||||||
Ok(MutationResult::Skipped)
|
Ok(MutationResult::Skipped)
|
||||||
} else {
|
} else {
|
||||||
let idx = rand.below(input.bytes().len() as u64 - 1) as usize;
|
let idx = rand.below(input.bytes().len() as u64) as usize;
|
||||||
unsafe {
|
unsafe {
|
||||||
// moar speed, no bound check
|
// moar speed, no bound check
|
||||||
let ptr = input.bytes_mut().get_unchecked_mut(idx) as *mut u8;
|
let ptr = input.bytes_mut().get_unchecked_mut(idx) as *mut u8;
|
||||||
@ -297,7 +297,7 @@ where
|
|||||||
I: Input + HasBytesVec,
|
I: Input + HasBytesVec,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
{
|
{
|
||||||
if input.bytes().len() <= 1 {
|
if input.bytes().len() < 2 {
|
||||||
Ok(MutationResult::Skipped)
|
Ok(MutationResult::Skipped)
|
||||||
} else {
|
} else {
|
||||||
let idx = rand.below(input.bytes().len() as u64 - 1) as usize;
|
let idx = rand.below(input.bytes().len() as u64 - 1) as usize;
|
||||||
@ -326,10 +326,10 @@ where
|
|||||||
I: Input + HasBytesVec,
|
I: Input + HasBytesVec,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
{
|
{
|
||||||
if input.bytes().len() <= 1 {
|
if input.bytes().len() < 4 {
|
||||||
Ok(MutationResult::Skipped)
|
Ok(MutationResult::Skipped)
|
||||||
} else {
|
} else {
|
||||||
let idx = rand.below(input.bytes().len() as u64 - 1) as usize;
|
let idx = rand.below(input.bytes().len() as u64 - 3) as usize;
|
||||||
unsafe {
|
unsafe {
|
||||||
// moar speed, no bound check
|
// moar speed, no bound check
|
||||||
let ptr = input.bytes_mut().get_unchecked_mut(idx) as *mut _ as *mut u32;
|
let ptr = input.bytes_mut().get_unchecked_mut(idx) as *mut _ as *mut u32;
|
||||||
@ -355,10 +355,10 @@ where
|
|||||||
I: Input + HasBytesVec,
|
I: Input + HasBytesVec,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
{
|
{
|
||||||
if input.bytes().len() <= 1 {
|
if input.bytes().len() < 8 {
|
||||||
Ok(MutationResult::Skipped)
|
Ok(MutationResult::Skipped)
|
||||||
} else {
|
} else {
|
||||||
let idx = rand.below(input.bytes().len() as u64 - 1) as usize;
|
let idx = rand.below(input.bytes().len() as u64 - 7) as usize;
|
||||||
unsafe {
|
unsafe {
|
||||||
// moar speed, no bound check
|
// moar speed, no bound check
|
||||||
let ptr = input.bytes_mut().get_unchecked_mut(idx) as *mut _ as *mut u64;
|
let ptr = input.bytes_mut().get_unchecked_mut(idx) as *mut _ as *mut u64;
|
||||||
@ -384,10 +384,10 @@ where
|
|||||||
I: Input + HasBytesVec,
|
I: Input + HasBytesVec,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
{
|
{
|
||||||
if input.bytes().len() <= 1 {
|
if input.bytes().len() == 0 {
|
||||||
Ok(MutationResult::Skipped)
|
Ok(MutationResult::Skipped)
|
||||||
} else {
|
} else {
|
||||||
let idx = rand.below(input.bytes().len() as u64 - 1) as usize;
|
let idx = rand.below(input.bytes().len() as u64) as usize;
|
||||||
let val = INTERESTING_8[rand.below(INTERESTING_8.len() as u64) as usize] as u8;
|
let val = INTERESTING_8[rand.below(INTERESTING_8.len() as u64) as usize] as u8;
|
||||||
unsafe {
|
unsafe {
|
||||||
// moar speed, no bound check
|
// moar speed, no bound check
|
||||||
@ -407,7 +407,7 @@ where
|
|||||||
I: Input + HasBytesVec,
|
I: Input + HasBytesVec,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
{
|
{
|
||||||
if input.bytes().len() <= 1 {
|
if input.bytes().len() < 2 {
|
||||||
Ok(MutationResult::Skipped)
|
Ok(MutationResult::Skipped)
|
||||||
} else {
|
} else {
|
||||||
let idx = rand.below(input.bytes().len() as u64 - 1) as usize;
|
let idx = rand.below(input.bytes().len() as u64 - 1) as usize;
|
||||||
@ -435,10 +435,10 @@ where
|
|||||||
I: Input + HasBytesVec,
|
I: Input + HasBytesVec,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
{
|
{
|
||||||
if input.bytes().len() <= 1 {
|
if input.bytes().len() < 4 {
|
||||||
Ok(MutationResult::Skipped)
|
Ok(MutationResult::Skipped)
|
||||||
} else {
|
} else {
|
||||||
let idx = rand.below(input.bytes().len() as u64 - 1) as usize;
|
let idx = rand.below(input.bytes().len() as u64 - 3) as usize;
|
||||||
let val = INTERESTING_32[rand.below(INTERESTING_8.len() as u64) as usize] as u32;
|
let val = INTERESTING_32[rand.below(INTERESTING_8.len() as u64) as usize] as u32;
|
||||||
unsafe {
|
unsafe {
|
||||||
// moar speed, no bound check
|
// moar speed, no bound check
|
||||||
|
@ -200,15 +200,15 @@ where
|
|||||||
rand: &mut R,
|
rand: &mut R,
|
||||||
state: &mut S,
|
state: &mut S,
|
||||||
input: &mut I,
|
input: &mut I,
|
||||||
_stage_idx: i32,
|
stage_idx: i32,
|
||||||
) -> Result<(), AflError> {
|
) -> Result<(), AflError> {
|
||||||
//self.scheduled.mutate(rand, corpus, input, stage_idx);
|
self.scheduled.mutate(rand, state, input, stage_idx)?;
|
||||||
let num = self.scheduled.iterations(rand, input);
|
/*let num = self.scheduled.iterations(rand, input);
|
||||||
for _ in 0..num {
|
for _ in 0..num {
|
||||||
let idx = self.scheduled.schedule(14, rand, input);
|
let idx = self.scheduled.schedule(14, rand, input);
|
||||||
let mutation = match idx {
|
let mutation = match idx {
|
||||||
0 => mutation_bitflip,
|
0 => mutation_bitflip,
|
||||||
/*1 => mutation_byteflip,
|
1 => mutation_byteflip,
|
||||||
2 => mutation_byteinc,
|
2 => mutation_byteinc,
|
||||||
3 => mutation_bytedec,
|
3 => mutation_bytedec,
|
||||||
4 => mutation_byteneg,
|
4 => mutation_byteneg,
|
||||||
@ -219,11 +219,11 @@ where
|
|||||||
8 => mutation_dwordadd,
|
8 => mutation_dwordadd,
|
||||||
9 => mutation_byteinteresting,
|
9 => mutation_byteinteresting,
|
||||||
10 => mutation_wordinteresting,
|
10 => mutation_wordinteresting,
|
||||||
11 => mutation_dwordinteresting,*/
|
11 => mutation_dwordinteresting,
|
||||||
_ => mutation_splice,
|
_ => mutation_splice,
|
||||||
};
|
};
|
||||||
mutation(self, rand, state, input)?;
|
mutation(self, rand, state, input)?;
|
||||||
}
|
}*/
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -277,7 +277,7 @@ where
|
|||||||
pub fn new_default() -> Self {
|
pub fn new_default() -> Self {
|
||||||
let mut scheduled = StdScheduledMutator::<C, I, R, S>::new();
|
let mut scheduled = StdScheduledMutator::<C, I, R, S>::new();
|
||||||
scheduled.add_mutation(mutation_bitflip);
|
scheduled.add_mutation(mutation_bitflip);
|
||||||
/*scheduled.add_mutation(mutation_byteflip);
|
scheduled.add_mutation(mutation_byteflip);
|
||||||
scheduled.add_mutation(mutation_byteinc);
|
scheduled.add_mutation(mutation_byteinc);
|
||||||
scheduled.add_mutation(mutation_bytedec);
|
scheduled.add_mutation(mutation_bytedec);
|
||||||
scheduled.add_mutation(mutation_byteneg);
|
scheduled.add_mutation(mutation_byteneg);
|
||||||
@ -301,7 +301,7 @@ where
|
|||||||
scheduled.add_mutation(mutation_bytesset);
|
scheduled.add_mutation(mutation_bytesset);
|
||||||
scheduled.add_mutation(mutation_bytesrandset);
|
scheduled.add_mutation(mutation_bytesrandset);
|
||||||
scheduled.add_mutation(mutation_bytescopy);
|
scheduled.add_mutation(mutation_bytescopy);
|
||||||
scheduled.add_mutation(mutation_bytesswap);*/
|
scheduled.add_mutation(mutation_bytesswap);
|
||||||
|
|
||||||
/* TODO
|
/* TODO
|
||||||
scheduled.add_mutation(mutation_tokeninsert);
|
scheduled.add_mutation(mutation_tokeninsert);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user