From:             matteo at beccati dot com
Operating system: Any
PHP version:      4.3.10
PHP Bug Type:     Filesystem function related
Bug description:  fread after tmpfile() reads only 8192 bytes

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 bug report at http://bugs.php.net/?id=32810&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32810&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32810&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32810&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32810&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32810&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32810&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32810&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32810&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32810&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32810&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32810&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32810&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32810&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32810&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32810&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32810&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32810&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32810&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32810&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32810&r=mysqlcfg

Reply via email to