mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-11 17:51:32 +00:00
fix the file descriptor without determining null
This commit is contained in:
@ -39,6 +39,7 @@ my_mutator_t *afl_custom_init(afl_state_t *afl, unsigned int seed) {
|
||||
data->afl = calloc(1, sizeof(afl_state_t));
|
||||
data->afl->queue_cycle = 1;
|
||||
data->afl->fsrv.dev_urandom_fd = open("/dev/urandom", O_RDONLY);
|
||||
if (data->afl->fsrv.dev_urandom_fd < 0) { PFATAL("Unable to open /dev/urandom"); }
|
||||
rand_set_seed(data->afl, getpid());
|
||||
|
||||
return data;
|
||||
|
@ -1611,6 +1611,7 @@ int main(int argc, char **argv_orig, char **envp) {
|
||||
if (in_dir || in_filelist) {
|
||||
|
||||
afl->fsrv.dev_urandom_fd = open("/dev/urandom", O_RDONLY);
|
||||
if (afl->fsrv.dev_urandom_fd < 0) { PFATAL("Unable to open /dev/urandom"); }
|
||||
afl->afl_env.afl_custom_mutator_library =
|
||||
getenv("AFL_CUSTOM_MUTATOR_LIBRARY");
|
||||
afl->afl_env.afl_python_module = getenv("AFL_PYTHON_MODULE");
|
||||
|
@ -67,6 +67,7 @@ static void test_rand_below(void **state) {
|
||||
rand_set_seed(&afl, 1337);
|
||||
|
||||
afl.fsrv.dev_urandom_fd = open("/dev/urandom", O_RDONLY);
|
||||
if (afl.fsrv.dev_urandom_fd < 0) { PFATAL("Unable to open /dev/urandom"); }
|
||||
|
||||
assert(!(rand_below(&afl, 9000) > 9000));
|
||||
assert_int_equal(rand_below(&afl, 1), 0);
|
||||
|
Reference in New Issue
Block a user