ID: 32810
Updated by: [EMAIL PROTECTED]
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
+Assigned To: tony2001
New Comment:
Testing the patch..
Previous Comments:
------------------------------------------------------------------------
[2005-05-22 00:32:22] [EMAIL PROTECTED]
php5-win32-200505191430 is still suffering from this.
------------------------------------------------------------------------
[2005-04-24 16:40:51] [EMAIL PROTECTED]
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