diff options
author | Joe Watkins <krakjoe@php.net> | 2016-10-18 11:30:33 +0100 |
---|---|---|
committer | Joe Watkins <krakjoe@php.net> | 2016-10-18 11:30:33 +0100 |
commit | 689cf8b2666e0bc9dff5c9216fedbf491890d3da (patch) | |
tree | ccc43f684899d8d482ed789800aee90e1d31b375 /ext/standard | |
parent | ac6134fb64f5aa89aa6ef7bda32c29079c86aea8 (diff) | |
download | php-git-689cf8b2666e0bc9dff5c9216fedbf491890d3da.tar.gz |
Revert "Fix bug #47890 #73215 uniqid() should use better random source"
This reverts commit 48f1a17886d874dc90867c669481804de90509e8.
Diffstat (limited to 'ext/standard')
-rw-r--r-- | ext/standard/uniqid.c | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/ext/standard/uniqid.c b/ext/standard/uniqid.c index 207cf01cb8..f429e6d4a0 100644 --- a/ext/standard/uniqid.c +++ b/ext/standard/uniqid.c @@ -35,11 +35,9 @@ #include <sys/time.h> #endif -#include "php_random.h" +#include "php_lcg.h" #include "uniqid.h" -#define PHP_UNIQID_ENTROPY_LEN 10 - /* {{{ proto string uniqid([string prefix [, bool more_entropy]]) Generates a unique ID */ #ifdef HAVE_GETTIMEOFDAY @@ -79,22 +77,7 @@ PHP_FUNCTION(uniqid) * digits for usecs. */ if (more_entropy) { - int i; - unsigned char c, entropy[PHP_UNIQID_ENTROPY_LEN+1]; - - for(i = 0; i < PHP_UNIQID_ENTROPY_LEN;) { - php_random_bytes_throw(&c, sizeof(c)); - /* Avoid modulo bias */ - if (c > 249) { - continue; - } - entropy[i] = c % 10 + '0'; - i++; - } - /* Set . for compatibility */ - entropy[1] = '.'; - entropy[PHP_UNIQID_ENTROPY_LEN] = '\0'; - uniqid = strpprintf(0, "%s%08x%05x%s", prefix, sec, usec, entropy); + uniqid = strpprintf(0, "%s%08x%05x%.8F", prefix, sec, usec, php_combined_lcg() * 10); } else { uniqid = strpprintf(0, "%s%08x%05x", prefix, sec, usec); } |