1
0
mirror of https://github.com/php/php-src.git synced 2026-03-31 12:42:29 +02:00

Merge branch 'PHP-7.0'

* PHP-7.0:
  Use arc4random on OpenBSD 5.5+ and NetBSD 7+
This commit is contained in:
Leigh
2015-10-30 19:11:09 +00:00
2 changed files with 10 additions and 0 deletions

View File

@@ -592,6 +592,11 @@ dnl Check for atomic operation API availability in Solaris
dnl
AC_CHECK_HEADERS([atomic.h])
dnl
dnl Check for arc4random on BSD systems
dnl
AC_CHECK_DECLS([arc4random_buf])
dnl
dnl Check for getrandom on newer Linux kernels
dnl

View File

@@ -33,6 +33,9 @@
#ifdef __linux__
# include <sys/syscall.h>
#endif
#if defined(__OpenBSD__) || defined(__NetBSD__)
# include <sys/param.h>
#endif
#ifdef ZTS
int random_globals_id;
@@ -87,6 +90,8 @@ static int php_random_bytes(void *bytes, size_t size)
zend_throw_exception(zend_ce_exception, "Could not gather sufficient random data", 0);
return FAILURE;
}
#elif HAVE_DECL_ARC4RANDOM_BUF && ((defined(__OpenBSD__) && OpenBSD >= 201405) || (defined(__NetBSD__) && __NetBSD_Version__ >= 700000001))
arc4random_buf(bytes, size);
#elif HAVE_DECL_GETRANDOM
/* Linux getrandom(2) syscall */
size_t read_bytes = 0;