summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkrakjoe <krakjoe@php.net>2017-11-22 04:30:59 +0000
committerkrakjoe <krakjoe@php.net>2017-11-22 04:30:59 +0000
commit5a7459a08202a893eca6fb8dedd7b007c9c8a219 (patch)
treeadc27182dca83fe7a946ad01da10295e7646e44b
parent3ad116b7bdfdb6ba485a1f1b5a63b3fd207dd63c (diff)
parent269d1601596341f574ff6c875a826ce2b671f1f0 (diff)
downloadphp-git-5a7459a08202a893eca6fb8dedd7b007c9c8a219.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Fix bug #75409
-rw-r--r--NEWS2
-rw-r--r--ext/standard/random.c12
2 files changed, 5 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index a9e2463af1..127da106dd 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,8 @@ PHP NEWS
(Remi)
. Fixed bug #75535 (Inappropriately parsing HTTP response leads to PHP
segment fault). (Nikita)
+ . Fixed bug #75409 (accept EFAULT in addition to ENOSYS as indicator
+ that getrandom() is missing). (sarciszewski)
- Zip:
. Fixed bug #75540 (Segfault with libzip 1.3.1). (Remi)
diff --git a/ext/standard/random.c b/ext/standard/random.c
index b52566cef0..a963c8f791 100644
--- a/ext/standard/random.c
+++ b/ext/standard/random.c
@@ -122,16 +122,10 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, zend_bool should_throw)
} else if (errno == EINTR || errno == EAGAIN) {
/* Try again */
continue;
+ } else {
+ /* If the syscall fails, fall back to reading from /dev/urandom */
+ break;
}
- /*
- If the syscall fails, we are doomed. The loop that calls
- php_random_bytes should be terminated by the exception instead
- of proceeding to demand more entropy.
- */
- if (should_throw) {
- zend_throw_exception(zend_ce_exception, "Could not gather sufficient random data", errno);
- }
- return FAILURE;
}
read_bytes += (size_t) n;