Skip to content

Commit 69c3f8c

Browse files
committed
- re apply the rng change specific to windows, long term it should be a std function but as this function was badly introduced in the 1st place, we have to fix the bad things here instead, pls do not revert again, bad idea.
1 parent 9620fb7 commit 69c3f8c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ext/openssl/openssl.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4926,10 +4926,19 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
49264926

49274927
buffer = emalloc(buffer_length + 1);
49284928

4929+
#ifdef PHP_WIN32
4930+
strong_result = 1;
4931+
/* random/urandom equivalent on Windows */
4932+
if (php_win32_get_random_bytes(buffer, (size_t) buffer_length) == FAILURE){
4933+
efree(buffer);
4934+
RETURN_FALSE;
4935+
}
4936+
#else
49294937
if ((strong_result = RAND_pseudo_bytes(buffer, buffer_length)) < 0) {
49304938
efree(buffer);
49314939
RETURN_FALSE;
49324940
}
4941+
#endif
49334942

49344943
buffer[buffer_length] = 0;
49354944
RETVAL_STRINGL((char *)buffer, buffer_length, 0);

0 commit comments

Comments
 (0)