summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/random.c
diff options
context:
space:
mode:
authorColin Guthrie <pulse@colin.guthr.ie>2008-08-03 19:56:49 +0100
committerColin Guthrie <pulse@colin.guthr.ie>2008-08-03 19:56:49 +0100
commit5744237a066186be305be9ea3ecb3ccccadcceca (patch)
tree6a08957a66fb308a8f1b37232d9b2d24a246e394 /src/pulsecore/random.c
parentb30a5d601eaffd98914ca0b9fdecd863eade0b4f (diff)
parent04ffac57a67eee9640f248b6fab33ee8367b0eab (diff)
Merge branch 'master' of git://git.0pointer.de/pulseaudio
Diffstat (limited to 'src/pulsecore/random.c')
-rw-r--r--src/pulsecore/random.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/pulsecore/random.c b/src/pulsecore/random.c
index 5deac37b..518c281a 100644
--- a/src/pulsecore/random.c
+++ b/src/pulsecore/random.c
@@ -37,7 +37,7 @@
#include "random.h"
-static int has_whined = 0;
+static pa_bool_t has_whined = TRUE;
static const char * const devices[] = { "/dev/urandom", "/dev/random", NULL };
@@ -77,6 +77,8 @@ static int random_proper(void *ret_data, size_t length) {
if (ret == 0)
break;
+
+ device++;
}
return ret;
@@ -87,9 +89,11 @@ void pa_random_seed(void) {
unsigned int seed;
if (random_proper(&seed, sizeof(unsigned int)) < 0) {
- if (!has_whined)
+
+ if (!has_whined) {
pa_log_warn("Failed to get proper entropy. Falling back to seeding with current time.");
- has_whined = 1;
+ has_whined = TRUE;
+ }
seed = (unsigned int) time(NULL);
}
@@ -107,9 +111,10 @@ void pa_random(void *ret_data, size_t length) {
if (random_proper(ret_data, length) >= 0)
return;
- if (!has_whined)
+ if (!has_whined) {
pa_log_warn("Failed to get proper entropy. Falling back to unsecure pseudo RNG.");
- has_whined = 1;
+ has_whined = TRUE;
+ }
for (p = ret_data, l = length; l > 0; p++, l--)
*p = (uint8_t) rand();