#35886 [Ver->Asn]: file_get_contents() fails with some combinations of offset & maxlen

From: Date: Thu, 05 Jan 2006 11:32:43 +0000
Subject: #35886 [Ver->Asn]: file_get_contents() fails with some combinations of offset & maxlen
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-91537@lists.php.net to get a copy of this message
 ID:               35886
 Updated by:       tony2001@php.net
 Reported By:      chris at lodesys dot com
-Status:           Verified
+Status:           Assigned
 Bug Type:         Reproducible crash
 Operating System: win32 only
 PHP Version:      5CVS-2006-01-03 (snap)
-Assigned To:      
+Assigned To:      wez
 New Comment:

Assigned to the maintainer.


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

[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.

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

[2006-01-04 01:25:08] sniper@php.net

Nuno, if you can reproduce -> provide the backtrace.

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

[2006-01-04 00:11:14] nlopess@php.net

I'm able to reproduce the crash on Windows XP.

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

[2006-01-03 20:01:56] chris at lodesys dot com

Description:
------------
This one is weird.  For some value of offset & maxlen,
file_get_contents will fail and crash PHP. (I'm running under Apache
1.3.34 and get a Dr. Watson).  The combination may have something to do
with offset + maxlen just above 4096, but even that's not consistant.

Reproduce code:
---------------
$x = file_get_contents("C:/php/news.txt", FALSE, NULL, 500, 3596);  //
WORKS

$x = file_get_contents("C:/php/news.txt", FALSE, NULL, 500, 3597);  //
FAILS

$x = file_get_contents("C:/php/news.txt", FALSE, NULL, 500, 4096);  //
FAILS

$x = file_get_contents("C:/php/news.txt", FALSE, NULL, 500, 4097);  //
WORKS


$x = file_get_contents("C:/php/news.txt", FALSE, NULL, 1000, 4096);  //
FAILS

$x = file_get_contents("C:/php/news.txt", FALSE, NULL, 1000, 4097);  //
WORKS

$x = file_get_contents("C:/php/news.txt", FALSE, NULL, 0, 4096);  //
WORKS

$x = file_get_contents("C:/php/news.txt", FALSE, NULL, 0, 4097);  //
WORKS


Expected result:
----------------
All combinations of offset & maxlen should work as news.txt is 74 KB
long. 

Actual result:
--------------
PHP fails in some instances (see above) with Dr. Watson reporting
"Application exception occurred: App:  (pid=1828)[apache.exe] Exception
number: c0000005 (access violation)"

Using 


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


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


Thread (15 messages)

« previous php.bugs (#91537) next »