Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Commit f4e97f8

Browse files
committed
[4.0] Fixed warnings when open_basedir directive set
1 parent 00a1bf4 commit f4e97f8

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Facebook/FacebookRedirectLoginHelper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ public function random($bytes)
241241
}
242242
$buf = '';
243243
// http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/
244-
if (is_readable('/dev/urandom')) {
244+
if (!ini_get('open_basedir')
245+
&& is_readable('/dev/urandom')) {
245246
$fp = fopen('/dev/urandom', 'rb');
246247
if ($fp !== FALSE) {
247248
$buf = fread($fp, $bytes);
@@ -251,7 +252,7 @@ public function random($bytes)
251252
}
252253
}
253254
}
254-
255+
255256
if (function_exists('mcrypt_create_iv')) {
256257
$buf = mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM);
257258
if ($buf !== FALSE) {

tests/FacebookRedirectLoginHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testCSPRNG()
6565
FacebookTestCredentials::$appId,
6666
FacebookTestCredentials::$appSecret
6767
);
68-
$this->assertTrue(preg_match('/^([0-9a-f]+)$/', $helper->random(32)));
68+
$this->assertEquals(1, preg_match('/^([0-9a-f]+)$/', $helper->random(32)));
6969
}
7070

7171
}

0 commit comments

Comments
 (0)