fixes for random number badness (lack of entropy and SIGFPE from RAND_cleanup

too early).


git-svn-id: file:///svn/unbound/trunk@907 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards
2008-01-28 14:34:53 +00:00
parent e5196b25ae
commit c8f2bf0333
15 changed files with 193 additions and 113 deletions
+4 -4
View File
@@ -363,12 +363,12 @@ infra_test()
static void
rnd_test()
{
struct ub_randstate r;
struct ub_randstate* r;
int num = 100, i;
long int a[100];
unit_assert( ub_initstate((unsigned)time(NULL), &r, 256) );
unit_assert( (r = ub_initstate((unsigned)time(NULL), NULL)) );
for(i=0; i<num; i++) {
a[i] = ub_random(&r);
a[i] = ub_random(r);
unit_assert(a[i] >= 0);
unit_assert((size_t)a[i] <= (size_t)RAND_MAX);
if(i > 5)
@@ -376,7 +376,7 @@ rnd_test()
a[i] != a[i-3] || a[i] != a[i-4] ||
a[i] != a[i-5] || a[i] != a[i-6]);
}
ub_randfree(&r);
ub_randfree(r);
}
/**