mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-13 02:28:09 +00:00
fix for *BSD: remove all HAVE_ARC4RANDOM dependencies
This commit is contained in:
@ -524,9 +524,7 @@ typedef struct afl_state {
|
|||||||
u64 stage_finds[32], /* Patterns found per fuzz stage */
|
u64 stage_finds[32], /* Patterns found per fuzz stage */
|
||||||
stage_cycles[32]; /* Execs per fuzz stage */
|
stage_cycles[32]; /* Execs per fuzz stage */
|
||||||
|
|
||||||
//#ifndef HAVE_ARC4RANDOM
|
|
||||||
u32 rand_cnt; /* Random number counter */
|
u32 rand_cnt; /* Random number counter */
|
||||||
//#endif
|
|
||||||
|
|
||||||
u64 rand_seed[4];
|
u64 rand_seed[4];
|
||||||
s64 init_seed;
|
s64 init_seed;
|
||||||
@ -958,13 +956,8 @@ uint64_t rand_next(afl_state_t *afl);
|
|||||||
|
|
||||||
static inline u32 rand_below(afl_state_t *afl, u32 limit) {
|
static inline u32 rand_below(afl_state_t *afl, u32 limit) {
|
||||||
|
|
||||||
//#ifdef HAVE_ARC4RANDOM
|
|
||||||
// if (unlikely(afl->fixed_seed)) { return random() % limit; }
|
|
||||||
|
|
||||||
/* The boundary not being necessarily a power of 2,
|
/* The boundary not being necessarily a power of 2,
|
||||||
we need to ensure the result uniformity. */
|
we need to ensure the result uniformity. */
|
||||||
// return arc4random_uniform(limit);
|
|
||||||
//#else
|
|
||||||
if (unlikely(!afl->rand_cnt--) && likely(!afl->fixed_seed)) {
|
if (unlikely(!afl->rand_cnt--) && likely(!afl->fixed_seed)) {
|
||||||
|
|
||||||
ck_read(afl->fsrv.dev_urandom_fd, &afl->rand_seed, sizeof(afl->rand_seed),
|
ck_read(afl->fsrv.dev_urandom_fd, &afl->rand_seed, sizeof(afl->rand_seed),
|
||||||
@ -974,9 +967,7 @@ static inline u32 rand_below(afl_state_t *afl, u32 limit) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return random() % limit;
|
|
||||||
return rand_next(afl) % limit;
|
return rand_next(afl) % limit;
|
||||||
//#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,12 +397,6 @@
|
|||||||
|
|
||||||
// #define IGNORE_FINDS
|
// #define IGNORE_FINDS
|
||||||
|
|
||||||
/* for *BSD: use ARC4RANDOM and save a file descriptor */
|
|
||||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
|
||||||
#ifndef HAVE_ARC4RANDOM
|
|
||||||
#define HAVE_ARC4RANDOM 1
|
|
||||||
#endif
|
|
||||||
#endif /* __APPLE__ || __FreeBSD__ || __OpenBSD__ */
|
|
||||||
|
|
||||||
#endif /* ! _HAVE_CONFIG_H */
|
#endif /* ! _HAVE_CONFIG_H */
|
||||||
|
|
||||||
|
@ -47,9 +47,8 @@ typedef struct afl_forkserver {
|
|||||||
out_dir_fd; /* FD of the lock file */
|
out_dir_fd; /* FD of the lock file */
|
||||||
|
|
||||||
s32 out_fd, /* Persistent fd for fsrv->out_file */
|
s32 out_fd, /* Persistent fd for fsrv->out_file */
|
||||||
#ifndef HAVE_ARC4RANDOM
|
|
||||||
dev_urandom_fd, /* Persistent fd for /dev/urandom */
|
dev_urandom_fd, /* Persistent fd for /dev/urandom */
|
||||||
#endif
|
|
||||||
dev_null_fd, /* Persistent fd for /dev/null */
|
dev_null_fd, /* Persistent fd for /dev/null */
|
||||||
fsrv_ctl_fd, /* Fork server control pipe (write) */
|
fsrv_ctl_fd, /* Fork server control pipe (write) */
|
||||||
fsrv_st_fd; /* Fork server status pipe (read) */
|
fsrv_st_fd; /* Fork server status pipe (read) */
|
||||||
|
@ -71,9 +71,8 @@ void afl_fsrv_init(afl_forkserver_t *fsrv) {
|
|||||||
fsrv->out_fd = -1;
|
fsrv->out_fd = -1;
|
||||||
fsrv->out_dir_fd = -1;
|
fsrv->out_dir_fd = -1;
|
||||||
fsrv->dev_null_fd = -1;
|
fsrv->dev_null_fd = -1;
|
||||||
#ifndef HAVE_ARC4RANDOM
|
|
||||||
fsrv->dev_urandom_fd = -1;
|
fsrv->dev_urandom_fd = -1;
|
||||||
#endif
|
|
||||||
/* Settings */
|
/* Settings */
|
||||||
fsrv->use_stdin = 1;
|
fsrv->use_stdin = 1;
|
||||||
fsrv->no_unlink = 0;
|
fsrv->no_unlink = 0;
|
||||||
@ -104,9 +103,7 @@ void afl_fsrv_init_dup(afl_forkserver_t *fsrv_to, afl_forkserver_t *from) {
|
|||||||
fsrv_to->map_size = from->map_size;
|
fsrv_to->map_size = from->map_size;
|
||||||
fsrv_to->support_shmem_fuzz = from->support_shmem_fuzz;
|
fsrv_to->support_shmem_fuzz = from->support_shmem_fuzz;
|
||||||
|
|
||||||
#ifndef HAVE_ARC4RANDOM
|
|
||||||
fsrv_to->dev_urandom_fd = from->dev_urandom_fd;
|
fsrv_to->dev_urandom_fd = from->dev_urandom_fd;
|
||||||
#endif
|
|
||||||
|
|
||||||
// These are forkserver specific.
|
// These are forkserver specific.
|
||||||
fsrv_to->out_dir_fd = -1;
|
fsrv_to->out_dir_fd = -1;
|
||||||
@ -421,9 +418,8 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv,
|
|||||||
|
|
||||||
close(fsrv->out_dir_fd);
|
close(fsrv->out_dir_fd);
|
||||||
close(fsrv->dev_null_fd);
|
close(fsrv->dev_null_fd);
|
||||||
#ifndef HAVE_ARC4RANDOM
|
|
||||||
close(fsrv->dev_urandom_fd);
|
close(fsrv->dev_urandom_fd);
|
||||||
#endif
|
|
||||||
if (fsrv->plot_file != NULL) { fclose(fsrv->plot_file); }
|
if (fsrv->plot_file != NULL) { fclose(fsrv->plot_file); }
|
||||||
|
|
||||||
/* This should improve performance a bit, since it stops the linker from
|
/* This should improve performance a bit, since it stops the linker from
|
||||||
|
@ -1541,10 +1541,8 @@ void setup_dirs_fds(afl_state_t *afl) {
|
|||||||
afl->fsrv.dev_null_fd = open("/dev/null", O_RDWR);
|
afl->fsrv.dev_null_fd = open("/dev/null", O_RDWR);
|
||||||
if (afl->fsrv.dev_null_fd < 0) { PFATAL("Unable to open /dev/null"); }
|
if (afl->fsrv.dev_null_fd < 0) { PFATAL("Unable to open /dev/null"); }
|
||||||
|
|
||||||
#ifndef HAVE_ARC4RANDOM
|
|
||||||
afl->fsrv.dev_urandom_fd = open("/dev/urandom", O_RDONLY);
|
afl->fsrv.dev_urandom_fd = open("/dev/urandom", O_RDONLY);
|
||||||
if (afl->fsrv.dev_urandom_fd < 0) { PFATAL("Unable to open /dev/urandom"); }
|
if (afl->fsrv.dev_urandom_fd < 0) { PFATAL("Unable to open /dev/urandom"); }
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Gnuplot output file. */
|
/* Gnuplot output file. */
|
||||||
|
|
||||||
|
@ -124,9 +124,7 @@ void afl_state_init(afl_state_t *afl, uint32_t map_size) {
|
|||||||
|
|
||||||
afl->stats_update_freq = 1;
|
afl->stats_update_freq = 1;
|
||||||
|
|
||||||
#ifndef HAVE_ARC4RANDOM
|
|
||||||
afl->fsrv.dev_urandom_fd = -1;
|
afl->fsrv.dev_urandom_fd = -1;
|
||||||
#endif
|
|
||||||
afl->fsrv.dev_null_fd = -1;
|
afl->fsrv.dev_null_fd = -1;
|
||||||
|
|
||||||
afl->fsrv.child_pid = -1;
|
afl->fsrv.child_pid = -1;
|
||||||
|
Reference in New Issue
Block a user