diff options
author | Andrea Fioraldi <andreafioraldi@gmail.com> | 2020-08-31 20:34:28 +0200 |
---|---|---|
committer | Andrea Fioraldi <andreafioraldi@gmail.com> | 2020-08-31 20:34:28 +0200 |
commit | 8ca4414d70df515b504beefddcc3ad3615a4216a (patch) | |
tree | ca8a552d322f4b2d79a9feff01f870e891813207 /include/afl-fuzz.h | |
parent | 6090bb1bca81229a4c6ae178e1cef0e35bd31a96 (diff) | |
parent | a552631d3b04da880f18a25860169ac4ccd8f85b (diff) | |
download | afl++-8ca4414d70df515b504beefddcc3ad3615a4216a.tar.gz |
merge conflicts
Diffstat (limited to 'include/afl-fuzz.h')
-rw-r--r-- | include/afl-fuzz.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index c5b01da8..f3a76492 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -1027,11 +1027,17 @@ static inline u32 rand_below(afl_state_t *afl, u32 limit) { } - /* Modulo is biased - we don't want our fuzzing to be biased so let's do it right. */ - u64 unbiased_rnd; + /* Modulo is biased - we don't want our fuzzing to be biased so let's do it + right. See: + https://stackoverflow.com/questions/10984974/why-do-people-say-there-is-modulo-bias-when-using-a-random-number-generator + */ + u64 unbiased_rnd; do { + unbiased_rnd = rand_next(afl); + } while (unlikely(unbiased_rnd >= (UINT64_MAX - (UINT64_MAX % limit)))); + return unbiased_rnd % limit; } |