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

index a1fb224396af5d0c974cdb490ce384ab435b6a40..dae1fce49c386de4fac5feef0eb83af78640cfdf 100755 (executable)
@@ -407,8 +407,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 c1ff46ce6b91faffa2108b001866d67ce5126fc9..7d2700e08ccd3221cdb264fe098745f80d1fe593 100755 (executable)
@@ -1162,7 +1162,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);