php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26752 fgets can't take variable as buffer length argument
Submitted: 2003-12-31 06:32 UTC Modified: 2004-01-01 19:53 UTC
From: jeroen dot pulles at redslider dot net Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 5.0.0b3 (beta3) OS: Windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jeroen dot pulles at redslider dot net
New email:
PHP Version: OS:

 

 [2003-12-31 06:32 UTC] jeroen dot pulles at redslider dot net
Description:
------------
fgets expects a literal for the buffer size argument. It hangs until the max_execution_time timeouts, when you give it a variable.



Reproduce code:
---------------
$url = 'http://www.google.com/';
if (($handle = fopen($url, 'r')) === false) {
    die('Couldnt open url '.$url.'.');
}
while (feof($handle) === false) {
    $text = fgets($handle, $kBufferSize); // doesn't work
    //$text = fgets($handle, 512); // works
    echo($text);
}
fclose($handle);

Expected result:
----------------
The google homepage (i.e. the given url)

Actual result:
--------------
Timeout on max_execution_time.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-31 06:34 UTC] jeroen dot pulles at redslider dot net
The reproduce code (obviously) lacks the $kBufferSize declaration.
$kBufferSize = 512; 
.... or something similar
 [2004-01-01 19:53 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC