com php-src: Revert "Fix bug #47890 #73215 uniqid() should use better random source": ext/standard/uniqid.c
| From: | Joe Watkins | Date: | Tue, 18 Oct 2016 10:30:19 +0000 |
| Subject: | com php-src: Revert "Fix bug #47890 #73215 uniqid() should use better random source": ext/standard/uniqid.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95190@lists.php.net to get a copy of this message | ||
Commit: 8c74be0c52d8d1d9c7304385b3c9c7a1bfb8b873
Author: Joe Watkins <krakjoe@php.net> Tue, 18 Oct 2016 11:30:19 +0100
Parents: 10a075fbd5edd784650e66c893c9037ee4290553
Branches: PHP-7.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8c74be0c52d8d1d9c7304385b3c9c7a1bfb8b873
Log:
Revert "Fix bug #47890 #73215 uniqid() should use better random source"
This reverts commit 48f1a17886d874dc90867c669481804de90509e8.
Bugs:
https://bugs.php.net/47890
https://bugs.php.net/73215
Changed paths:
M ext/standard/uniqid.c
Diff:
diff --git a/ext/standard/uniqid.c b/ext/standard/uniqid.c
index 207cf01..f429e6d 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);
}