Hi!
Thank you for all your work on LibAFL!
While looking at the numeric mutators, I noticed that the BitFlipMutator uses size_of::<I>() as the upper bound for the flipped bits index, but afaik size_of returns the byte size of the type.
|
let offset = state.rand_mut().choose(0..size_of::<I>()).unwrap(); |
|
input.flip_bit_at(offset); |
This would make the mutator only ever flip 1/8th of the possible bits (assuming all bits are used).
Since I was implementing Numeric for a custom type, I'd love to see a fix that extends Numeric with a bits() method instead of multiplying the result of size_of by eight.
I'd be more than happy to create a PR for whatever solution you prefer.
Hi!
Thank you for all your work on LibAFL!
While looking at the numeric mutators, I noticed that the BitFlipMutator uses
size_of::<I>()as the upper bound for the flipped bits index, but afaiksize_ofreturns the byte size of the type.LibAFL/crates/libafl/src/mutators/numeric.rs
Lines 272 to 273 in df17dc2
This would make the mutator only ever flip 1/8th of the possible bits (assuming all bits are used).
Since I was implementing
Numericfor a custom type, I'd love to see a fix that extendsNumericwith abits()method instead of multiplying the result ofsize_ofby eight.I'd be more than happy to create a PR for whatever solution you prefer.