From: Kurt Zeilenga Date: Tue, 26 Oct 1999 23:54:39 +0000 (+0000) Subject: Rework counter code in fallback. X-Git-Tag: UCDATA_2_4~315 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9e0958d5bc342e2f35f6ee8aaa6cf179b2d55085;p=openldap Rework counter code in fallback. --- diff --git a/libraries/liblutil/entropy.c b/libraries/liblutil/entropy.c index 5ff122b378..75e321155c 100644 --- a/libraries/liblutil/entropy.c +++ b/libraries/liblutil/entropy.c @@ -44,12 +44,13 @@ int lutil_entropy( char *buf, int nbytes ) * but implementation 100% OpenLDAP. So don't blame Phil. */ /* worse case is this is a MD5 hash of a counter, if * MD5 is a strong cryptographic hash, this should - * be fairly resisant to attack + * be fairly resistant to attack */ - static int initialized = 0; + static int counter = 0; int n; struct { + int counter; pid_t pid; #ifdef HAVE_GETTIMEOFDAY @@ -60,11 +61,7 @@ int lutil_entropy( char *buf, int nbytes ) unsigned long junk; } rdata; - if( !initialized ) { - initialized++; - - rdata.pid = getpid(); - } + rdata.pid = getpid(); for( n = 0; n < nbytes; n += 16 ) { struct lutil_MD5Context ctx; @@ -76,6 +73,7 @@ int lutil_entropy( char *buf, int nbytes ) (void) time( &rdata.time ); #endif + rdata.counter = ++counter; rdata.pid++; rdata.junk++;