]> granicus.if.org Git - libevent/commitdiff
Avoid other RNG initialization FS reads when urandom file is specified
authorNick Mathewson <nickm@torproject.org>
Tue, 13 Aug 2013 14:59:27 +0000 (10:59 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 13 Aug 2013 14:59:27 +0000 (10:59 -0400)
arc4random.c

index 048057031408d9e2f7f68af50ad55c1087ce1bd2..4b6f5f2f12ad920b5a2ecd5c56f28587a3cd270a 100644 (file)
@@ -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