Skip to content

Commit

Permalink
Fix bug #75409
Browse files Browse the repository at this point in the history
  • Loading branch information
paragonie-scott authored and krakjoe committed Nov 22, 2017
1 parent 38be3c4 commit 269d160
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 3 additions & 9 deletions ext/standard/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 269d160

Please sign in to comment.