com php-src: Fix use of uninitialised value in uniqid() where more_entropy=0: ext/standard/uniqid.c

From: Date: Tue, 01 Aug 2017 12:58:00 +0000
Subject: com php-src: Fix use of uninitialised value in uniqid() where more_entropy=0: ext/standard/uniqid.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-98889@lists.php.net to get a copy of this message
Commit: ad5222c3a6bb2e22ee7ea77b47ef2eebde696fa0 Author: Julien Pauli <jpauli@php.net> Tue, 1 Aug 2017 14:42:15 +0200 Parents: b8da481a2a08ee65a2190ca1e1fc6e89e0ace457 Branches: PHP-7.2 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ad5222c3a6bb2e22ee7ea77b47ef2eebde696fa0 Log: Fix use of uninitialised value in uniqid() where more_entropy=0 Changed paths: M ext/standard/uniqid.c Diff: diff --git a/ext/standard/uniqid.c b/ext/standard/uniqid.c index e8f2f19..8a6091a 100644 --- a/ext/standard/uniqid.c +++ b/ext/standard/uniqid.c @@ -58,19 +58,17 @@ PHP_FUNCTION(uniqid) Z_PARAM_BOOL(more_entropy) ZEND_PARSE_PARAMETERS_END(); - if (!more_entropy) { - /* This implementation needs current microsecond to change, - * hence we poll time until it does. This is much faster than - * calling usleep(1) which may cause the kernel to schedule - * another process, causing a pause of around 10ms. - */ - do { - (void)gettimeofday((struct timeval *) &tv, (struct timezone *) NULL); - } while (tv.tv_sec == prev_tv.tv_sec && tv.tv_usec == prev_tv.tv_usec); + /* This implementation needs current microsecond to change, + * hence we poll time until it does. This is much faster than + * calling usleep(1) which may cause the kernel to schedule + * another process, causing a pause of around 10ms. + */ + do { + (void)gettimeofday((struct timeval *) &tv, (struct timezone *) NULL); + } while (tv.tv_sec == prev_tv.tv_sec && tv.tv_usec == prev_tv.tv_usec); - prev_tv.tv_sec = tv.tv_sec; - prev_tv.tv_usec = tv.tv_usec; - } + prev_tv.tv_sec = tv.tv_sec; + prev_tv.tv_usec = tv.tv_usec; sec = (int) tv.tv_sec; usec = (int) (tv.tv_usec % 0x100000);

« previous php.cvs (#98889) next »