Skip to content

Commit 49d0d7b

Browse files
authored
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()`.
1 parent 6910167 commit 49d0d7b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

ext/standard/uniqid.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@ PHP_FUNCTION(uniqid)
7575
uint32_t bytes;
7676
double seed;
7777
if (php_random_bytes_silent(&bytes, sizeof(uint32_t)) == FAILURE) {
78-
seed = php_combined_lcg() * 10;
79-
} else {
80-
seed = ((double) bytes / UINT32_MAX) * 10.0;
78+
bytes = php_random_generate_fallback_seed();
8179
}
80+
seed = ((double) bytes / UINT32_MAX) * 10.0;
8281
uniqid = strpprintf(0, "%s%08x%05x%.8F", prefix, sec, usec, seed);
8382
} else {
8483
uniqid = strpprintf(0, "%s%08x%05x", prefix, sec, usec);

0 commit comments

Comments
 (0)