#32810 [Asn]: fread after tmpfile() reads only 8192 bytes
| From: | lsmith@php.net | Date: | Sat, 21 May 2005 22:32:23 +0000 |
| Subject: | #32810 [Asn]: fread after tmpfile() reads only 8192 bytes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-79323@lists.php.net to get a copy of this message | ||
ID: 32810
Updated by: lsmith@php.net
Reported By: matteo at beccati dot com
Status: Assigned
Bug Type: Filesystem function related
Operating System: *
PHP Version: 5CVS, 4CVS (2005-04-24)
Assigned To: wez
New Comment:
php5-win32-200505191430 is still suffering from this.
Previous Comments:
------------------------------------------------------------------------
[2005-04-24 16:40:51] sniper@php.net
Wez breaks, Wez fixes. (Streams stuff broke this)
------------------------------------------------------------------------
[2005-04-24 16:04:54] matteo at beccati dot com
Description:
------------
In recent PHP versions, fread only reads 8192 bytes from a file
generated with tmpfile().
I've already seen bug reports #29023 and #30936 which seem strongly
related to this issue. From what I can see, fread on local files isn't
limited to the PHP chunk size of 8192, while a fread on a tmpfile acts
like it was i.e. a network stream, breaking backwards compatibility. I
found out this issue investigating a recently reported bug for
phpAdsNew, which uses this function to deal with remote ftp-stored
files.
IMVHO this can be considered a bug in in the tmpfile() implementation.
If you don't agree, well... I suggest to mark it as a documentation
bug, because I couldn't find nothing related to the 8192 bytes limit in
the manual.
Versions/OS tested and affected:
PHP 4.3.10 Linux
PHP 4.3.11 FreeBSD and Windows
PHP 5.0.4 Windows
Versions/OS tested and unaffected:
PHP 4.3.4 Windows
Reproduce code:
---------------
<?php
$fp = tmpfile();
// This would give the correct result
// $fp = fopen('/tmp/test.dat', 'w+');
fwrite($fp, str_repeat('0', 100000));
$size = ftell($fp);
rewind($fp);
$buf = fread($fp, $size);
echo "Bytes written: ".$size."\n";
echo "Bytes read: ".strlen($buf)."\n";
fclose($fp);
?>
Expected result:
----------------
Bytes written: 100000
Bytes read: 100000
Actual result:
--------------
Bytes written: 100000
Bytes read: 8192
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32810&edit=1