|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74105 PHP on Linux should use /dev/urandom when getrandom is not available
Submitted: 2017-02-16 08:32 UTC Modified: 2017-02-17 17:44 UTC
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: bruno+archlinux at ahennezel dot info Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 7.1.2RC1 OS: Linux
Private report: No CVE-ID: None
 [2017-02-16 08:32 UTC] bruno+archlinux at ahennezel dot info
When PHP is compiled on a recent kernel, it assumes that getrandom is available.
When such a PHP build is running on an older kernel, this code throws an exception.

cf. pull request 2385

Test script:
$a = random_int(0,10);

Expected result:
Fallback to /dev/urandom and return a number
Exit with a more explicit error message (checking ENOSYS)

Actual result:
PHP Fatal error:  Uncaught Exception: Could not gather sufficient random data in -:2
Stack trace:
#0 -(2): random_int(0, 200)
#1 {main}
  thrown in - on line 2


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-16 08:56 UTC]
-Summary: PHP hangs when getrandom is not available +Summary: PHP on Linux should use /dev/urandom when getrandom is not available -Type: Bug +Type: Feature/Change Request -Package: Reproducible crash +Package: *General Issues
 [2017-02-17 17:44 UTC]
Automatic comment on behalf of
Log: Fixed bug #74105
 [2017-02-17 17:44 UTC]
-Status: Open +Status: Closed
 [2017-02-17 17:44 UTC]
-Type: Feature/Change Request +Type: Bug -Assigned To: +Assigned To: nikic
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Feb 25 18:01:26 2024 UTC