]> granicus.if.org Git - php/commitdiff
Fixed bug #19749 (shouldn't mmap() files larger than memory_limit)
authorWez Furlong <wez@php.net>
Wed, 21 Apr 2004 12:02:47 +0000 (12:02 +0000)
committerWez Furlong <wez@php.net>
Wed, 21 Apr 2004 12:02:47 +0000 (12:02 +0000)
NEWS
main/streams/mmap.c

diff --git a/NEWS b/NEWS
index 9335b99a351f9168cf4ccdc9a74e72b0cf3ee567..7ec1278b86ebf306315fdafe105452da87324b6a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,7 @@ PHP                                                                        NEWS
 - Fixed bug #27397 (debug_backtrace() not showing function arguments). (Zeev)
 - Fixed bug #27283 (The last catch statement was sometimes skipped). (Andi)
 - Fixed bug #26441 (When __set() returned a value it corrupted it). (Andi)
+- Fixed bug #19749 (shouldn't mmap() files larger than memory_limit). (Wez)
 
 18 March 2004, PHP 5 Release Candidate 1
 - Fixed numerous bugs with the just-in-time auto-global initialization, that
index 443faf384dc232b91c82733f0aca0bf307b0b79b..82bfa623f10dc3cfc062cfdb4ef32be3b4e4940d 100644 (file)
@@ -31,7 +31,11 @@ PHPAPI char *_php_stream_mmap_range(php_stream *stream, size_t offset, size_t le
        range.mode = mode;
        range.mapped = NULL;
 
-       /* TODO: Enforce system policy and limits for mmap sizes ? */
+       /* For now, we impose an arbitrary 1MB limit to avoid
+        * runaway swapping when large files are passed thru. */
+       if (length > 1 * 1024 * 1024) {
+               return NULL;
+       }
        
        if (PHP_STREAM_OPTION_RETURN_OK == php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_MAP_RANGE, &range)) {
                if (mapped_len) {