From 9695e9c192b866793110c885fb87143de8cebf2a Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 13 Aug 2013 10:59:27 -0400 Subject: Avoid other RNG initialization FS reads when urandom file is specified --- arc4random.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'arc4random.c') 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 -- cgit v1.2.1