Skip to content

Use php_random_bytes_silent() where possible in gmp_init_random() #10944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ext/gmp/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,11 @@ static void gmp_init_random(void)
/* Initialize */
gmp_randinit_mt(GMPG(rand_state));
/* Seed */
gmp_randseed_ui(GMPG(rand_state), GENERATE_SEED());
zend_long seed = 0;
if (php_random_bytes_silent(&seed, sizeof(zend_long)) == FAILURE) {
seed = GENERATE_SEED();
}
gmp_randseed_ui(GMPG(rand_state), seed);

GMPG(rand_initialized) = 1;
}
Expand Down