diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-08-13 10:59:27 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-08-13 10:59:27 -0400 |
commit | 9695e9c192b866793110c885fb87143de8cebf2a (patch) | |
tree | f6208782db70de2694c139b4394f8427915830ac | |
parent | d44f91ad7915ad08ad2b6dad3e52902edc619ef2 (diff) | |
download | libevent-9695e9c192b866793110c885fb87143de8cebf2a.tar.gz |
Avoid other RNG initialization FS reads when urandom file is specified
-rw-r--r-- | arc4random.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/arc4random.c b/arc4random.c index 04805703..4b6f5f2f 100644 --- a/arc4random.c +++ b/arc4random.c @@ -326,10 +326,13 @@ arc4_seed_urandom(void) return arc4_seed_urandom_helper_(arc4random_urandom_filename); for (i = 0; filenames[i]; ++i) { - if (arc4_seed_urandom_helper_(filenames[i]) == 0) + if (arc4_seed_urandom_helper_(filenames[i]) == 0) { + printf("okay %s\n", filenames[i]); return 0; + } } + puts("FAIL"); return -1; } #endif @@ -350,7 +353,8 @@ arc4_seed(void) ok = 1; #endif #ifdef TRY_SEED_PROC_SYS_KERNEL_RANDOM_UUID - if (0 == arc4_seed_proc_sys_kernel_random_uuid()) + if (arc4random_urandom_filename == NULL && + 0 == arc4_seed_proc_sys_kernel_random_uuid()) ok = 1; #endif #ifdef TRY_SEED_SYSCTL_LINUX |