From: sviver at vnet dot hu Operating system: Windows XP prof. PHP version: 5.1.4 PHP Bug Type: Filesystem function related Bug description: fread() strange behaviour
Description: ------------ I open a file of about 600kb, then loop over it with feof and fread, and echo the read data to the output. In a previous php version (>5, <5.1.4) it returned random characters, but the file size was correct. So I upgraded to 5.1.4 to see whether the problem is still there. With the new version there are no random characters, but the result is much smaller than the original file. Sometimes it's 73728 (=72*1024) bytes, somtimes 24576 (=24*1024), sometimes 98304 (also divisible), sometimes 81920 (also divisible). Etc. The previous version also started producing strange output after reading several block correctly - the new version simply stops reading. With the previous version the problem disappered if I set the block size to 1*1028. With the new version it persists. There is no error message at the end of the file. Reproduce code: --------------- <?php $filename='../data/temp/temp_output/5741921624893711'; header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="test.file"'); $packet = 4*1024; $buff = ''; $F = fopen($filename, 'rb'); while (!feof($F)) { $buff = fread($F, $packet); echo $buff; } fclose($F); ?> Expected result: ---------------- The complete file as a download. Actual result: -------------- Part of the file. -- Edit bug report at http://bugs.php.net/?id=37939&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37939&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37939&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37939&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37939&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37939&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37939&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37939&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37939&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37939&r=support Expected behavior: http://bugs.php.net/fix.php?id=37939&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37939&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37939&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37939&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37939&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37939&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37939&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37939&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37939&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37939&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37939&r=mysqlcfg