cvs: ZendEngine2(PHP_5_3) / zend_stream.c /tests bug47596.phpt php-src NEWS

[email protected] ("Dmitry Stogov") Thu, 26 Mar 2009 17:28:49 -0000
Newsgroups php.zend-engine.cvs
Message-ID <cvsdmitry1238088529@cvsserver>
dmitry		Thu Mar 26 17:28:49 2009 UTC

  Added files:                 (Branch: PHP_5_3)
    /ZendEngine2/tests	bug47596.phpt 

  Modified files:              
    /php-src	NEWS 
    /ZendEngine2	zend_stream.c 
  Log:
  Fixed bug #47596 (Bus error on parsing file)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.538&r2=1.2027.2.547.2.965.2.539&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.538 php-src/NEWS:1.2027.2.547.2.965.2.539
--- php-src/NEWS:1.2027.2.547.2.965.2.538	Thu Mar 26 12:53:39 2009
+++ php-src/NEWS	Thu Mar 26 17:28:49 2009
@@ -9,6 +9,7 @@
 - Fixed bug #47714 (autoloading classes inside exception_handler leads to
   crashes). (Dmitry)
 - Fixed bug #47699 (autoload and late static binding). (Dmitry)
+- Fixed bug #47596 (Bus error on parsing file). (Dmitry)
 - Fixed bug #47516 (nowdoc can not be embed in heredoc but can be embed in
   double quote). (Dmitry)
 - Fixed bug #47038 (Memory leak in include). (Dmitry)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_stream.c?r1=1.13.2.1.2.1.2.10&r2=1.13.2.1.2.1.2.11&diff_format=u
Index: ZendEngine2/zend_stream.c
diff -u ZendEngine2/zend_stream.c:1.13.2.1.2.1.2.10 ZendEngine2/zend_stream.c:1.13.2.1.2.1.2.11
--- ZendEngine2/zend_stream.c:1.13.2.1.2.1.2.10	Wed Jan 28 23:18:49 2009
+++ ZendEngine2/zend_stream.c	Thu Mar 26 17:28:49 2009
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_stream.c,v 1.13.2.1.2.1.2.10 2009/01/28 23:18:49 nlopess Exp $ */
+/* $Id: zend_stream.c,v 1.13.2.1.2.1.2.11 2009/03/26 17:28:49 dmitry Exp $ */
 
 
 #include "zend.h"
@@ -29,6 +29,9 @@
 #include <sys/stat.h>
 #if HAVE_SYS_MMAN_H
 # include <sys/mman.h>
+# ifndef PAGE_SIZE
+#  define PAGE_SIZE 4096
+# endif
 #endif
 
 ZEND_DLIMPORT int isatty(int fd);
@@ -212,7 +215,9 @@
 
 	if (old_type == ZEND_HANDLE_FP && !file_handle->handle.stream.isatty && size) {
 #if HAVE_MMAP
-		if (file_handle->handle.fp) {
+		if (file_handle->handle.fp &&
+		    size != 0 &&
+		    ((size - 1) % PAGE_SIZE) <= PAGE_SIZE - ZEND_MMAP_AHEAD) {
 			/*  *buf[size] is zeroed automatically by the kernel */
 			*buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), 0);
 			if (*buf != MAP_FAILED) {

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug47596.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug47596.phpt
+++ ZendEngine2/tests/bug47596.phpt