summaryrefslogtreecommitdiff
path: root/main/streams/mmap.c
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2004-04-21 12:02:47 +0000
committerWez Furlong <wez@php.net>2004-04-21 12:02:47 +0000
commit0fb4bf9771051eb8cd37d83d4d8c26e6957986eb (patch)
tree876268acc1d9a966d9c3304b7ab32df7c6485f66 /main/streams/mmap.c
parent206f0da25a12700fff17435267d620251ebc584a (diff)
downloadphp-git-0fb4bf9771051eb8cd37d83d4d8c26e6957986eb.tar.gz
Fixed bug #19749 (shouldn't mmap() files larger than memory_limit)
Diffstat (limited to 'main/streams/mmap.c')
-rw-r--r--main/streams/mmap.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/main/streams/mmap.c b/main/streams/mmap.c
index 443faf384d..82bfa623f1 100644
--- a/main/streams/mmap.c
+++ b/main/streams/mmap.c
@@ -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) {