Bug #70742 [Nab]: random_bytes() fails when the SYSTEMROOT env var is empty
| From: | ab@php.net | Date: | Tue, 20 Oct 2015 14:51:30 +0000 |
| Subject: | Bug #70742 [Nab]: random_bytes() fails when the SYSTEMROOT env var is empty | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-196706@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70742&edit=1
ID: 70742
Updated by: ab@php.net
Reported by: nicolas dot grekas+php at gmail dot com
Summary: random_bytes() fails when the SYSTEMROOT env var is
empty
Status: Not a bug
Type: Bug
Package: mcrypt related
Operating System: Windows
PHP Version: 7.0.0RC5
Block user comment: N
Private report: N
New Comment:
OK, I didn't think about it from this POV, but yes -proc_open() actually doesn't merge
env. Btw. it'll be much easier in 7.1, getenv() without arguments will deliver the whole env
vars (Ferenc already merged it).
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2015-10-20 13:09:01] nicolas dot grekas+php at gmail dot com
"Not a bug" is fine by me, I mostly wanted to get feedback on this behaviour and document
it somewhere.
This can happen more frequently by using proc_open(): when one sets the $env argument, it's
easy to miss some important vars there.
------------------------------------------------------------------------
[2015-10-20 11:16:03] ab@php.net
Thanks for the report. Why would you want to manipulate this env variable? Doing so, you'll
probably break not only this but many other things.
In this particular case, since the default crypto service provider is used, the corresponding DLL
will fail to load. Consequently CryptAcquireContext() will fail. This is expected behavior.
Thanks.
------------------------------------------------------------------------
[2015-10-19 14:56:06] nicolas dot grekas+php at gmail dot com
Description:
------------
On Windows, both random_bytes and mcrypt_create_iv fail when the SYSTEMROOT env var is not set.
Test script:
---------------
<?php
putenv('SYSTEMROOT=');
echo strlen(random_bytes(1));
Expected result:
----------------
1
Actual result:
--------------
PHP Warning: mcrypt_create_iv(): Could not gather sufficient random data
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70742&edit=1