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:
Tim Düsterhus 2024-08-04 18:26:40 +02:00 committed by GitHub
parent 6910167c48
commit 49d0d7bcd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -75,10 +75,9 @@ PHP_FUNCTION(uniqid)
uint32_t bytes;
double seed;
if (php_random_bytes_silent(&bytes, sizeof(uint32_t)) == FAILURE) {
seed = php_combined_lcg() * 10;
} else {
seed = ((double) bytes / UINT32_MAX) * 10.0;
bytes = php_random_generate_fallback_seed();
}
seed = ((double) bytes / UINT32_MAX) * 10.0;
uniqid = strpprintf(0, "%s%08x%05x%.8F", prefix, sec, usec, seed);
} else {
uniqid = strpprintf(0, "%s%08x%05x", prefix, sec, usec);