tony2001 Wed Nov 29 11:12:59 2006 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/standard/tests/file bug39673.phpt
Modified files:
/php-src NEWS
/php-src/main/streams plain_wrapper.c
Log:
MFH: fix #39673 (file_get_contents causes bus error on certain offsets)
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.381&r2=1.2027.2.547.2.382&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.381 php-src/NEWS:1.2027.2.547.2.382
--- php-src/NEWS:1.2027.2.547.2.381 Tue Nov 28 18:59:52 2006
+++ php-src/NEWS Wed Nov 29 11:12:59 2006
@@ -43,8 +43,10 @@
php_filter.h).
- Fixed wrong signature initialization in imagepng (Takeshi Abe)
- Added optimization for imageline with horizontal and vertial lines (Pierre)
-- Fixed bug #39662 (Segfault when calling asXML() of a cloned
SimpleXMLElement).
+- Fixed bug #39673 (file_get_contents causes bus error on certain offsets).
(Tony)
+- Fixed bug #39662 (Segfault when calling asXML() of a cloned
SimpleXMLElement).
+ (Rob, Tony)
- Fixed bug #39656 (crash when calling fetch() on a PDO statment object
after closeCursor()). (Ilia, Tony)
- Fixed bug #39653 (ext/dba doesn't check for db-4.5 and db-4.4 when db4
http://cvs.php.net/viewvc.cgi/php-src/main/streams/plain_wrapper.c?r1=1.52.2.6.2.12&r2=1.52.2.6.2.13&diff_format=u
Index: php-src/main/streams/plain_wrapper.c
diff -u php-src/main/streams/plain_wrapper.c:1.52.2.6.2.12
php-src/main/streams/plain_wrapper.c:1.52.2.6.2.13
--- php-src/main/streams/plain_wrapper.c:1.52.2.6.2.12 Thu Nov 16 16:06:51 2006
+++ php-src/main/streams/plain_wrapper.c Wed Nov 29 11:12:59 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: plain_wrapper.c,v 1.52.2.6.2.12 2006/11/16 16:06:51 bjori Exp $ */
+/* $Id: plain_wrapper.c,v 1.52.2.6.2.13 2006/11/29 11:12:59 tony2001 Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -627,9 +627,16 @@
case PHP_STREAM_MMAP_MAP_RANGE:
do_fstat(data, 1);
+ if (range->length == 0 &&
range->offset > 0 && range->offset < data->sb.st_size) {
+ range->length =
data->sb.st_size - range->offset;
+ }
if (range->length == 0 ||
range->length > data->sb.st_size) {
range->length =
data->sb.st_size;
}
+ if (range->offset >=
data->sb.st_size) {
+ range->offset =
data->sb.st_size;
+ range->length = 0;
+ }
switch (range->mode) {
case
PHP_STREAM_MAP_MODE_READONLY:
prot =
PROT_READ;
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug39673.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/bug39673.phpt
+++ php-src/ext/standard/tests/file/bug39673.phpt
--TEST--
Bug #39673 (file_get_contents causes bus error on certain offsets)
--FILE--
<?php
$str = str_repeat("test", 3456);
$filename = dirname(__FILE__).'/bug39673.txt';
file_put_contents($filename, $str);
$offsets = array(
-1,
0,
3456*4,
3456*4 - 1,
3456*4 + 1,
2000,
5000,
100000,
);
foreach ($offsets as $offset) {
$r = file_get_contents($filename, false, null, $offset);
var_dump(strlen($r));
}
@unlink($filename);
echo "Done\n";
?>
--EXPECTF--
int(13824)
int(13824)
int(0)
int(1)
int(0)
int(11824)
int(8824)
int(0)
Done
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php