#27511 [Opn->Bgs]: fread crashes Apache with mistakenly big length
| From: | iliaa@php.net | Date: | Sat, 06 Mar 2004 19:11:04 +0000 |
| Subject: | #27511 [Opn->Bgs]: fread crashes Apache with mistakenly big length | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-56006@lists.php.net to get a copy of this message | ||
ID: 27511
Updated by: iliaa@php.net
Reported By: patrick at borgeat dot de
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: Windows 2000 SR4
PHP Version: 5.0.0b4 (beta4)
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
When you call fread() PHP will try to allocate enough
memory to store all of the data that you want to read.
Meaning that in your case it'll try to allocate
approximately 1078508183 bytes. This fails and causes the
script to exit OR if you have enough memory and/or swap try
to allocate this much memory which would take a VERY long
time.
Previous Comments:
------------------------------------------------------------------------
[2004-03-06 07:07:46] patrick at borgeat dot de
I forgot a Semikolon (;) after "echo $res", sorry!
------------------------------------------------------------------------
[2004-03-06 04:53:43] patrick at borgeat dot de
Description:
------------
As I mistakenly tried to read a very large number of bytes (1078508183)
(more than are in the file) with fread, the Site doesn't react anymore
and i get a apache.exe Task in my Tasklist consuming an average of 80%
CPU Load (with a 1300 Mhz Machine) which can't be stopped (maybe also
due to missing rights). Also the file is blocked.
Never tested this on Linux, but I think if a server does this
mistakenly several times at once the whole server enviroment would
crash.
I run Apache 2.0.48 with PHP 5.0.0b4 as Apache2 Handler on Windows 2000
SR4 on FAT32 Filesystem.
Reproduce code:
---------------
(in my case test was a textfile with the 3 Letters "AAA")
<?
$fp = fopen("test",r");
$res = fread($fp,1078508183);
echo $res
fclose($fp);
?>
Expected result:
----------------
I expected PHP to be as smart (as it is with smaller numbers for
example like 50 000) to write only 3 Bytes and output "AAA".
Actual result:
--------------
Apache Task isn't stopable and runs @ Average of 80% CPU Load
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27511&edit=1