php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #75409
Patch accept-eperm-and-efault-for-missing-syscall revision 2017-10-20 09:45 UTC by martin dot zdrahal at s-team dot at

Patch accept-eperm-and-efault-for-missing-syscall for *Encryption and hash functions Bug #75409

Patch version 2017-10-20 09:45 UTC

Return to Bug #75409 | Download this patch
Patch Revisions:

Developer: martin.zdrahal@s-team.at

diff --git a/ext/standard/random.c b/ext/standard/random.c
index b52566cef0..6bc7d9bec8 100644
--- a/ext/standard/random.c
+++ b/ext/standard/random.c
@@ -113,7 +113,7 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, zend_bool should_throw)
 		n = syscall(SYS_getrandom, bytes + read_bytes, amount_to_read, 0);
 
 		if (n == -1) {
-			if (errno == ENOSYS) {
+			if (errno == ENOSYS || errno == EPERM || errno == EFAULT) {
 				/* This can happen if PHP was compiled against a newer kernel where getrandom()
 				 * is available, but then runs on an older kernel without getrandom(). If this
 				 * happens we simply fall back to reading from /dev/urandom. */
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Thu Dec 13 00:01:26 2018 UTC