cvs: php-src /ext/standard/tests/file bug39673.phpt /main/streams plain_wrapper.c
| From: | Antony Dovgal | Date: | Wed, 29 Nov 2006 11:10:49 +0000 |
| Subject: | cvs: php-src /ext/standard/tests/file bug39673.phpt /main/streams plain_wrapper.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-41773@lists.php.net to get a copy of this message | ||
tony2001 Wed Nov 29 11:10:49 2006 UTC
Added files:
/php-src/ext/standard/tests/file bug39673.phpt
Modified files:
/php-src/main/streams plain_wrapper.c
Log:
fix #39673 (file_get_contents causes bus error on certain offsets)
http://cvs.php.net/viewvc.cgi/php-src/main/streams/plain_wrapper.c?r1=1.78&r2=1.79&diff_format=u
Index: php-src/main/streams/plain_wrapper.c
diff -u php-src/main/streams/plain_wrapper.c:1.78 php-src/main/streams/plain_wrapper.c:1.79
--- php-src/main/streams/plain_wrapper.c:1.78 Thu Nov 16 16:08:09 2006
+++ php-src/main/streams/plain_wrapper.c Wed Nov 29 11:10:49 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: plain_wrapper.c,v 1.78 2006/11/16 16:08:09 bjori Exp $ */
+/* $Id: plain_wrapper.c,v 1.79 2006/11/29 11:10:49 tony2001 Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -631,9 +631,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