File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -592,6 +592,11 @@ dnl Check for atomic operation API availability in Solaris
592
592
dnl
593
593
AC_CHECK_HEADERS ( [ atomic.h] )
594
594
595
+ dnl
596
+ dnl Check for arc4random on BSD systems
597
+ dnl
598
+ AC_CHECK_DECLS ( [ arc4random_buf] )
599
+
595
600
dnl
596
601
dnl Setup extension sources
597
602
dnl
Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ static int php_random_bytes(void *bytes, size_t size)
39
39
php_error_docref (NULL , E_WARNING , "Could not gather sufficient random data" );
40
40
return FAILURE ;
41
41
}
42
+ #else
43
+ #if HAVE_DECL_ARC4RANDOM_BUF
44
+ arc4random_buf (bytes , size );
42
45
#else
43
46
int fd = -1 ;
44
47
size_t read_bytes = 0 ;
@@ -47,8 +50,8 @@ static int php_random_bytes(void *bytes, size_t size)
47
50
#else
48
51
#if HAVE_DEV_URANDOM
49
52
fd = open ("/dev/urandom" , O_RDONLY );
50
- #endif
51
- #endif
53
+ #endif // URANDOM
54
+ #endif // ARANDOM
52
55
if (fd < 0 ) {
53
56
php_error_docref (NULL , E_WARNING , "Cannot open source device" );
54
57
return FAILURE ;
@@ -67,7 +70,8 @@ static int php_random_bytes(void *bytes, size_t size)
67
70
php_error_docref (NULL , E_WARNING , "Could not gather sufficient random data" );
68
71
return FAILURE ;
69
72
}
70
- #endif
73
+ #endif // !ARC4RANDOM_BUF
74
+ #endif // !WIN32
71
75
72
76
return SUCCESS ;
73
77
}
You can’t perform that action at this time.
0 commit comments