From:             kier at vbulletin dot com
Operating system: Redhat Linux 8.0
PHP version:      4.3.2
PHP Bug Type:     *Directory/Filesystem functions
Bug description:  fread() exits prematurely on files opened over HTTP

After switching from PHP 4.3.2 RC2 to PHP 4.3.2 RC4 I noticed that a lot of
my scripts failed to properly open the files they were asked to...

Here is an example script that works fine under PHP 4.3.2 RC2 but breaks
under 4.3.2 RC4 and later. I have not tried 4.3.2 RC3 so I can't say
whether the problem was introduced at the RC3 or RC4 stage. Nonetheless,
the problem still exists in PHP 4.3.2 Final.

<?php

$path = 'http://www.domain.com/some/large/page.html';

$fp = fopen($path, 'r');
$contents = fread($fp, 99999999);

echo '<pre>' . htmlspecialchars($contents) . '</pre>';

?>

This will output the HTML source of the page referenced in $path, but
under recent versions of PHP 4.3.2 the contents is truncated, having not
reached the end of the file.

It is worth noting that using

$contents = '';
while (!feof($fp))
{
    $contents .= fgets($fp, 100);
}

does not exhibit the fread() truncation problem, and neither does using
fread() on LOCAL files. The problem seems isolated to opening remote files
over HTTP with fread();

I have verified this bug on several servers under different PHP
configurations.
-- 
Edit bug report at http://bugs.php.net/?id=23874&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=23874&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=23874&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=23874&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=23874&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=23874&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=23874&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=23874&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=23874&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=23874&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=23874&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23874&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=23874&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=23874&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=23874&r=gnused

Reply via email to