about summary refs log tree commit diff
path: root/include/afl-fuzz.h
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-04-02 16:41:33 +0200
committervan Hauser <vh@thc.org>2020-04-09 10:23:37 +0200
commite8e6dbf83962900eb9a0909ca4f2e8aeea6d96e9 (patch)
tree02f97bf65e9fe9cfa6ba08dac48556bf787247a5 /include/afl-fuzz.h
parent5602a09cc61371fcb2527963368bc99dbc66ff8d (diff)
downloadafl++-e8e6dbf83962900eb9a0909ca4f2e8aeea6d96e9.tar.gz
small enhancements and code-format
Diffstat (limited to 'include/afl-fuzz.h')
-rw-r--r--include/afl-fuzz.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h
index a9165064..56135d0e 100644
--- a/include/afl-fuzz.h
+++ b/include/afl-fuzz.h
@@ -935,13 +935,13 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len,
 static inline u32 rand_below(afl_state_t *afl, u32 limit) {
 
 #ifdef HAVE_ARC4RANDOM
-  if (afl->fixed_seed) { return random() % limit; }
+  if (unlikely(afl->fixed_seed)) { return random() % limit; }
 
   /* The boundary not being necessarily a power of 2,
      we need to ensure the result uniformity. */
   return arc4random_uniform(limit);
 #else
-  if (!afl->fixed_seed && unlikely(!afl->rand_cnt--)) {
+  if (unlikely(!afl->rand_cnt--) && likely(!afl->fixed_seed)) {
 
     ck_read(afl->fsrv.dev_urandom_fd, &afl->rand_seed, sizeof(afl->rand_seed),
             "/dev/urandom");
@@ -957,7 +957,7 @@ static inline u32 rand_below(afl_state_t *afl, u32 limit) {
 
 static inline u32 get_rand_seed(afl_state_t *afl) {
 
-  if (afl->fixed_seed) return (u32)afl->init_seed;
+  if (unlikely(afl->fixed_seed)) return (u32)afl->init_seed;
   return afl->rand_seed[0];
 
 }