com php-src: Fix bug #75409: NEWS ext/standard/random.c

From: Date: Wed, 22 Nov 2017 04:26:54 +0000
Subject: com php-src: Fix bug #75409: NEWS ext/standard/random.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-100338@lists.php.net to get a copy of this message
Commit: 269d1601596341f574ff6c875a826ce2b671f1f0 Author: Scott <scott@paragonie.com> Tue, 21 Nov 2017 22:02:07 -0500 Committer: krakjoe <krakjoe@php.net> Wed, 22 Nov 2017 04:26:54 +0000 Parents: 38be3c4ac445adbdf06883b1e9d3f106d986755e Branches: PHP-7.0 PHP-7.1 PHP-7.2 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=269d1601596341f574ff6c875a826ce2b671f1f0 Log: Fix bug #75409 Bugs: https://bugs.php.net/75409 Changed paths: M NEWS M ext/standard/random.c Diff: diff --git a/NEWS b/NEWS index d2b9a05..fd54b03 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,8 @@ PHP NEWS - Standard: . 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 b52566c..a963c8f 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;

« previous php.cvs (#100338) next »