#29100 [NEW]: fread ignores memory_limit
| From: | pickleman78 at sbcglobal dot net | Date: | Sun, 11 Jul 2004 20:41:00 +0000 |
| Subject: | #29100 [NEW]: fread ignores memory_limit | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-62063@lists.php.net to get a copy of this message | ||
From: pickleman78 at sbcglobal dot net
Operating system: WIndows XP
PHP version: 4.3.6
PHP Bug Type: Reproducible crash
Bug description: fread ignores memory_limit
Description:
------------
I am getting a crash from PHP when I mistakenly attempt to read
1,761,607,681 bytes from an incoming socket. Now I would reasonably assume
that since this is far above the memory limit set in my PHP.ini file
memory_limit = 8M
I would expect it to stop before even attempting to allocate such a
rediculous ammount of memory for the script. In this case it fails with a
FATAL: emalloc() unable to allocate 1761607681 bytes. Should this be what
it does? I would expect it to issue an ERROR as opposed to crashing.
Reproduce code:
---------------
<?php
$fp=fsockopen("http://php.net");
$data=fread($fp,1761607681);
?>
Expected result:
----------------
It would be expected to receive an error as opposed to PHP trying to
allocate this memory
Actual result:
--------------
Stated above, causes
FATAL: emalloc() could not......
--
Edit bug report at http://bugs.php.net/?id=29100&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29100&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29100&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29100&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29100&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29100&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29100&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29100&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29100&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29100&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29100&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29100&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29100&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29100&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29100&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29100&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29100&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29100&r=float