mirror of
https://github.com/php/php-src.git
synced 2024-09-23 19:07:26 +00:00
- use php_win32_get_random_bytes instead of over slow and partially wrong openssl's version
This commit is contained in:
parent
04432e7dd8
commit
8278f831a5
@ -4920,10 +4920,19 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
|
||||
|
||||
buffer = emalloc(buffer_length + 1);
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
strong_result = 1;
|
||||
/* random/urandom equivalent on Windows */
|
||||
if (php_win32_get_random_bytes(buffer, (size_t) buffer_length) == FAILURE){
|
||||
efree(buffer);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
#else
|
||||
if ((strong_result = RAND_pseudo_bytes(buffer, buffer_length)) < 0) {
|
||||
efree(buffer);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
buffer[buffer_length] = 0;
|
||||
RETVAL_STRINGL((char *)buffer, buffer_length, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user