mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
standard: Stop using php_combined_lcg()
in uniqid()
(#15217)
Fall back to the fallback generator if the CSPRNG fails instead. This removes the last internal user of `php_combined_lcg()`.
This commit is contained in:
parent
6910167c48
commit
49d0d7bcd7
@ -75,10 +75,9 @@ PHP_FUNCTION(uniqid)
|
|||||||
uint32_t bytes;
|
uint32_t bytes;
|
||||||
double seed;
|
double seed;
|
||||||
if (php_random_bytes_silent(&bytes, sizeof(uint32_t)) == FAILURE) {
|
if (php_random_bytes_silent(&bytes, sizeof(uint32_t)) == FAILURE) {
|
||||||
seed = php_combined_lcg() * 10;
|
bytes = php_random_generate_fallback_seed();
|
||||||
} else {
|
|
||||||
seed = ((double) bytes / UINT32_MAX) * 10.0;
|
|
||||||
}
|
}
|
||||||
|
seed = ((double) bytes / UINT32_MAX) * 10.0;
|
||||||
uniqid = strpprintf(0, "%s%08x%05x%.8F", prefix, sec, usec, seed);
|
uniqid = strpprintf(0, "%s%08x%05x%.8F", prefix, sec, usec, seed);
|
||||||
} else {
|
} else {
|
||||||
uniqid = strpprintf(0, "%s%08x%05x", prefix, sec, usec);
|
uniqid = strpprintf(0, "%s%08x%05x", prefix, sec, usec);
|
||||||
|
Loading…
Reference in New Issue
Block a user