#35886 [Com]: file_get_contents() fails with some combinations of offset & maxlen

From: Date: Thu, 02 Mar 2006 21:50:15 +0000
Subject: #35886 [Com]: file_get_contents() fails with some combinations of offset & maxlen
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-93861@lists.php.net to get a copy of this message
 ID:               35886
 Comment by:       piecia2000 at tlen dot pl
 Reported By:      chris at lodesys dot com
 Status:           Assigned
 Bug Type:         Streams related
 Operating System: win32 only
 PHP Version:      5CVS-2006-01-03 (snap)
 Assigned To:      wez
 New Comment:

Temporary solution (slighty slower):

  $fd = fopen($filename, "rb");
  fseek($fd, $offset);
  $file = fread($fd, $size);
  fclose($fd);

please fix file_get_contents(),


Previous Comments:
------------------------------------------------------------------------

[2006-02-23 07:21:30] ninive at gmx dot at

Please fix this critical bug.

------------------------------------------------------------------------

[2006-02-08 02:23:46] chris at lodesys dot com

The example test file is C:/php/news.txt (part of the PHP Windows
distribution).  It is 74 KB (75,800 bytes).  Was having problems with
files larger than that (say up to 170 KB).  Didn't test with extra
large files.

------------------------------------------------------------------------

[2006-02-08 00:50:26] iliaa@php.net

How big is the file?

------------------------------------------------------------------------

[2006-01-05 02:21:26] nlopess@php.net

OK, the problem is in the MapViewOfFile() call in
php_stdiop_set_option(), because it is mapping less data than we've
asked.
It seems a windows problem to me, but I'm leaving open because this can
be a serious bug (although I'm not able to fix it..).

------------------------------------------------------------------------

[2006-01-05 00:26:24] nlopess@php.net

OK, back from the school exams, the problem seems to be in
php_stdiop_set_option(), because it is allocating one less byte than it
should. (and that mmap code is specific for windows).

I'll try to investigate the problem further and produce a patch.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/35886

-- 
Edit this bug report at http://bugs.php.net/?id=35886&edit=1


Thread (15 messages)

« previous php.bugs (#93861) next »