Skip to content

Commit 2b395f7

Browse files
committed
random: Remove check for HAVE_DEV_URANDOM
It cannot be decided whether the device is available at build time, PHP might run in a container or chroot that does not expose the device. Simply attempt to open it, if it does not exist it will fail. This improves readability of php_random_bytes() by removing one layer of preprocessor conditions.
1 parent 21e5dfc commit 2b395f7

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

ext/random/random.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,7 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw)
557557

558558
if (fd < 0) {
559559
errno = 0;
560-
# if HAVE_DEV_URANDOM
561560
fd = open("/dev/urandom", O_RDONLY);
562-
# endif
563561
if (fd < 0) {
564562
if (should_throw) {
565563
if (errno != 0) {

0 commit comments

Comments
 (0)