]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
rng fixup.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 9 Jan 2008 10:48:10 +0000 (10:48 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 9 Jan 2008 10:48:10 +0000 (10:48 +0000)
git-svn-id: file:///svn/unbound/branches/beta-0.7@826 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
util/random.c

index 01afb9454d1d10eeb3669ea7984edce8b61fa8f6..0908ee39f3f658da18aee5a45ef323707c6824e3 100644 (file)
@@ -1,3 +1,7 @@
+9 January 2008: Wouter
+       - fixup openssl RAND problem, when the system is not configured to
+         give entropy, and the rng needs to be seeded. (for 0.7.2)
+
 3 December 2007: Wouter
        - Fixup building in a subdirectory. (for 0.7.2)
 
index 19a72834bc3ac13173a2337dfa77b71dad92084f..3f3611d9c08837ed5c059e76ca5cd59a18b9314a 100644 (file)
@@ -92,7 +92,7 @@ ub_arc4random_stir(struct ub_hiddenstate* s)
 }
 
 int 
-ub_initstate(unsigned int ATTR_UNUSED(seed), struct ub_randstate* state, 
+ub_initstate(unsigned int seed, struct ub_randstate* state, 
        unsigned long ATTR_UNUSED(n))
 {
        state->s = calloc(1, sizeof(*state->s));
@@ -103,9 +103,13 @@ ub_initstate(unsigned int ATTR_UNUSED(seed), struct ub_randstate* state,
 
        /* RAND_ is threadsafe, by the way */
        if(!RAND_status()) {
-               log_err("Random generator has no entropy (error %ld)",
-                   ERR_get_error());
-               return 0;
+               /* try to seed it */
+               RAND_seed(&seed, (int)sizeof(seed));
+               if(!RAND_status()) {
+                       log_err("Random generator has no entropy (error %ld)",
+                               ERR_get_error());
+                       return 0;
+               }
        }
        ub_arc4random_stir(state->s);
        return 1;