Description: don't mmap large files
Author: Marc Deslauriers <marc.deslauriers@ubuntu.com>
Bug: http://bugs.php.net/bug.php?id=52102
Ubuntu-Bug: https://bugs.edge.launchpad.net/ubuntu/+source/php5/+bug/564920

--- php5.orig/main/streams/plain_wrapper.c
+++ php5/main/streams/plain_wrapper.c
@@ -656,7 +656,13 @@ static int php_stdiop_set_option(php_str
 				
 				switch (value) {
 					case PHP_STREAM_MMAP_SUPPORTED:
-						return fd == -1 ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK;
+						if (fd == -1)
+							return PHP_STREAM_OPTION_RETURN_ERR;
+						/* Don't mmap large files */
+						do_fstat(data, 1);
+						if (data->sb.st_size > 4 * 1024 * 1024)
+							return PHP_STREAM_OPTION_RETURN_ERR;
+						return PHP_STREAM_OPTION_RETURN_OK;
 
 					case PHP_STREAM_MMAP_MAP_RANGE:
 						do_fstat(data, 1);
