Skip to content

Commit

Permalink
Avoid other RNG initialization FS reads when urandom file is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
nmathewson committed Aug 13, 2013
1 parent d44f91a commit 9695e9c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arc4random.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9695e9c

Please sign in to comment.