#29023 [NEW]: fread() only reads 8192 bytes from a local file
| From: | benjcarson at digitaljunkies dot ca | Date: | Mon, 05 Jul 2004 20:28:51 +0000 |
| Subject: | #29023 [NEW]: fread() only reads 8192 bytes from a local file | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-61714@lists.php.net to get a copy of this message | ||
From: benjcarson at digitaljunkies dot ca
Operating system: Linux
PHP version: 5CVS-2004-07-05 (dev)
PHP Bug Type: Filesystem function related
Bug description: fread() only reads 8192 bytes from a local file
Description:
------------
In the latest cvs snap, fread() does not read more than 8192 bytes from a
local file, despite specifying a larger read size as the second parameter.
If the fread() call is wrapped in a while (!feof) loop the file can be
read correctly, but only 8k at a time. This contradicts the first example
in the manual (http://www.php.net/manual/en/function.fread.php) and is a BC
break.
As far as I can tell the change was made sometime between the 2004-06-22
snap and the 2004-07-04 snap.
I've tested both using my php.ini file and without (i.e. using the
built-in defaults). I configured using the following command:
./configure --prefix=/usr --with-apxs=/usr/bin/apxs \
--enable-memory-limit \
--with-layout-GNU\
--enable-bcmath \
--enable-calendar \
--with-curl=/usr \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-shmop \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-bz2 \
--with-config-file-path=/etc/php5/apache \
--with-gd=/usr \
--with-freetype-dir=shared,/usr \
--with-jpeg-dir=/usr \
--with-png-dir=shared,/usr \
--with-ttf=shared,/usr \
--with-xpm-dir=shared,/usr/X11R6 \
--with-gettext \
--with-kerberos=/usr \
--with-ldap=shared,/usr \
--with-mhash=shared,/usr \
--with-mm \
--with-ncurses=/usr \
--with-openssl=/usr \
--with-pcre-regex=/usr \
--with-pear \
--with-pgsql \
--with-pspell=/usr \
--with-zlib \
--with-zlib-dir=/usr
Reproduce code:
---------------
#!/usr/bin/php
<?php
$filename = "/some/largish/local/file";
$fd = fopen($filename, 'r');
$contents = fread($fd, filesize($filename));
echo strlen($contents) ."\n";
fclose($fd);
?>
Expected result:
----------------
(the file's actual size, in bytes)
Actual result:
--------------
8192
--
Edit bug report at http://bugs.php.net/?id=29023&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29023&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29023&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29023&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29023&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29023&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29023&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29023&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29023&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29023&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29023&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29023&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29023&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29023&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29023&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29023&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29023&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29023&r=float