Skip to content
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions ext/random/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ AC_CHECK_HEADERS([CommonCrypto/CommonRandom.h], [], [],
#include <CommonCrypto/CommonCryptoError.h>
])

dnl
dnl Mostly for non Linux systems
dnl
AC_CHECK_FUNCS([getrandom])

dnl
dnl Setup extension
dnl
Expand Down
4 changes: 2 additions & 2 deletions ext/random/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

#if HAVE_SYS_PARAM_H
# include <sys/param.h>
# if (__FreeBSD__ && __FreeBSD_version > 1200000) || (__DragonFly__ && __DragonFly_version >= 500700) || defined(__sun)
# if (__FreeBSD__ && __FreeBSD_version > 1200000) || (__DragonFly__ && __DragonFly_version >= 500700) || (defined(__sun) && defined(HAVE_GETRANDOM))
# include <sys/random.h>
# endif
#endif
Expand Down Expand Up @@ -511,7 +511,7 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw)
#else
size_t read_bytes = 0;
ssize_t n;
# if (defined(__linux__) && defined(SYS_getrandom)) || (defined(__FreeBSD__) && __FreeBSD_version >= 1200000) || (defined(__DragonFly__) && __DragonFly_version >= 500700) || defined(__sun)
# if (defined(__linux__) && defined(SYS_getrandom)) || (defined(__FreeBSD__) && __FreeBSD_version >= 1200000) || (defined(__DragonFly__) && __DragonFly_version >= 500700) || (defined(__sun) && defined(HAVE_GETRANDOM))
/* Linux getrandom(2) syscall or FreeBSD/DragonFlyBSD getrandom(2) function*/
/* Keep reading until we get enough entropy */
while (read_bytes < size) {
Expand Down