]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #29801 (Set limit on the size of mmapable data).
authorIlia Alshanetsky <iliaa@php.net>
Mon, 15 Nov 2004 23:44:14 +0000 (23:44 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 15 Nov 2004 23:44:14 +0000 (23:44 +0000)
NEWS
main/php_streams.h
main/streams/streams.c

diff --git a/NEWS b/NEWS
index 1e5fa97ae3363cb7adfa882b7c01b348a9178018..e86f78b6483d3e10051d57dc03f66b2b0443754c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ PHP                                                                        NEWS
 - Extended the functionality of is_subclass_of() to accept either a class name
   or an object as first parameter. (Andrey) 
 - Fixed potential problems with unserializing invalid serialize data. (Marcus)
+- Fixed bug #29801 (Set limit on the size of mmapable data). (Ilia)
 - Fixed bug #30783 (Apache crash when using ReflectionFunction::
   getStaticVariables()). (Marcus)
 - Fixed bug #30750 (Meaningful error message when upload directory is not 
index 000b4291c3ecf761d4b0ca7776664b53fd49e1b1..d6499ce89603e3e3643872890fc20b3eddd71971 100755 (executable)
@@ -410,8 +410,11 @@ END_EXTERN_C()
 #define PHP_STREAM_OPTION_RETURN_NOTIMPL       -2 /* underlying stream does not implement; streams can handle it instead */
 
 /* copy up to maxlen bytes from src to dest.  If maxlen is PHP_STREAM_COPY_ALL, copy until eof(src).
- * Uses mmap if the src is a plain file and at offset 0 */
-#define PHP_STREAM_COPY_ALL            -1
+ * Uses mmap if the src is a plain file and at offset 0 
+ * To ensure we don't take up too much memory when reading large files, set the default mmap length
+ * at this many bytes */
+#define PHP_STREAM_COPY_ALL            2000000
+
 BEGIN_EXTERN_C()
 PHPAPI size_t _php_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen STREAMS_DC TSRMLS_DC);
 #define php_stream_copy_to_stream(src, dest, maxlen)   _php_stream_copy_to_stream((src), (dest), (maxlen) STREAMS_CC TSRMLS_CC)
index 7692005743e2cc8c3d38e94b30fc9510e2d163dc..6a6b030931787518c76609f06a6286271ab9d34d 100755 (executable)
@@ -1151,7 +1151,7 @@ PHPAPI size_t _php_stream_passthru(php_stream * stream STREAMS_DC TSRMLS_DC)
                char *p;
                size_t mapped;
 
-               p = php_stream_mmap_range(stream, php_stream_tell(stream), 0, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped);
+               p = php_stream_mmap_range(stream, php_stream_tell(stream), PHP_STREAM_COPY_ALL, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped);
 
                if (p) {
                        PHPWRITE(p, mapped);