From: Kurt Zeilenga Date: Wed, 27 Oct 1999 00:08:31 +0000 (+0000) Subject: Make sure rdata differs for each program. X-Git-Tag: UCDATA_2_4~314 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=241799c9e3e305cd771e14600032dd01b0778806;p=openldap Make sure rdata differs for each program. --- diff --git a/libraries/liblutil/entropy.c b/libraries/liblutil/entropy.c index 75e321155c..4a15a789d4 100644 --- a/libraries/liblutil/entropy.c +++ b/libraries/liblutil/entropy.c @@ -49,8 +49,12 @@ int lutil_entropy( char *buf, int nbytes ) static int counter = 0; int n; - struct { + struct rdata_s { int counter; + + char *buf; + struct rdata_s *stack; + pid_t pid; #ifdef HAVE_GETTIMEOFDAY @@ -61,18 +65,25 @@ int lutil_entropy( char *buf, int nbytes ) unsigned long junk; } rdata; + /* make sure rdata differs for each process */ rdata.pid = getpid(); - + + /* make sure rdata differs for each program */ + rdata.buf = buf; + rdata.stack = &rdata; + for( n = 0; n < nbytes; n += 16 ) { struct lutil_MD5Context ctx; char digest[16]; + /* hopefully has good resolution */ #ifdef HAVE_GETTIMEOFDAY (void) gettimeofday( &rdata.tv, sizeof( rdata.tv ) ); #else (void) time( &rdata.time ); #endif + /* make sure rdata differs */ rdata.counter = ++counter; rdata.pid++; rdata.junk++;