Skip to content

Commit 60cc376

Browse files
committed
Drop Windows specific implementation of openssl_random_pseudo_bytes()
Despite commit 69c3f8c[1] claiming otherwise, there is no need for any Windows specific implementation here. Users can use random_bytes(), if they desire so. [1] <69c3f8c> Closes GH-9153.
1 parent 3c01646 commit 60cc376

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

ext/openssl/openssl.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7652,15 +7652,6 @@ PHP_OPENSSL_API zend_string* php_openssl_random_pseudo_bytes(zend_long buffer_le
76527652
}
76537653
buffer = zend_string_alloc(buffer_length, 0);
76547654

7655-
#ifdef PHP_WIN32
7656-
/* random/urandom equivalent on Windows */
7657-
if (php_win32_get_random_bytes((unsigned char*)(buffer)->val, (size_t) buffer_length) == FAILURE){
7658-
zend_string_release_ex(buffer, 0);
7659-
zend_throw_exception(zend_ce_exception, "Error reading from source device", 0);
7660-
return NULL;
7661-
}
7662-
#else
7663-
76647655
PHP_OPENSSL_CHECK_LONG_TO_INT_NULL_RETURN(buffer_length, length);
76657656
PHP_OPENSSL_RAND_ADD_TIME();
76667657
if (RAND_bytes((unsigned char*)ZSTR_VAL(buffer), (int)buffer_length) <= 0) {
@@ -7670,7 +7661,7 @@ PHP_OPENSSL_API zend_string* php_openssl_random_pseudo_bytes(zend_long buffer_le
76707661
} else {
76717662
php_openssl_store_errors();
76727663
}
7673-
#endif
7664+
76747665
return buffer;
76757666
}
76767667

0 commit comments

Comments
 (0)