Bug #68986 [Opn->Csd]: pointer returned by php_stream_fopen_temporary_file not validated in memory.c
| From: | laruence@php.net | Date: | Thu, 05 Feb 2015 08:41:21 +0000 |
| Subject: | Bug #68986 [Opn->Csd]: pointer returned by php_stream_fopen_temporary_file not validated in memory.c | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-190473@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68986&edit=1
ID: 68986
Updated by: laruence@php.net
Reported by: nayana at ddproperty dot com
Summary: pointer returned by php_stream_fopen_temporary_file
not validated in memory.c
-Status: Open
+Status: Closed
Type: Bug
Package: Streams related
Operating System: Linux
PHP Version: master-Git-2015-02-05 (Git)
-Assigned To:
+Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2015-02-05 04:25:56] nayana at ddproperty dot com
Description:
------------
it seems that the pointer returned by php_stream_fopen_temporary_file / php_stream_fopen_tmpfile is
not validated prior to use in memory.c in the case where a script is executed in an environment
where the TMPDIR is not writable to the user, it will cause a SIGSEGV.
from the script side any code that utilize php://temp with 2MB+ buffer with the above condition will
encounter this issue.
i have fixed the problem on all the calling code in memory.c using php_error_docref, i see that in
phar they have handled the condition with zend_throw_exception_ex. i am not in a position to decide
which one is best at this time. i think a friendly warning is better than a SIGSEGV at this point :)
i have validated this problem exists on github-master and releases 5.4.37, 5.4.17
i will post my pull-request in a comment
Test script:
---------------
#mkdir /tmp/x
#chmod 444 /tmp/x
#export TMPDIR=/tmp/x
$fp = fopen('php://temp', 'r+');
$data = implode('', array_fill(0, (1024 * 1024 * 2), 'A'));
fwrite($fp, $data);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68986&edit=1