Created
January 6, 2024 21:07
-
-
Save nielsdos/53e0a8dee060c12854cf6fd706f2e4f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/main/streams/streams.c b/main/streams/streams.c | |
index e1399927b2..a78b021870 100644 | |
--- a/main/streams/streams.c | |
+++ b/main/streams/streams.c | |
@@ -1645,16 +1645,21 @@ PHPAPI zend_result _php_stream_copy_to_stream_ex(php_stream *src, php_stream *de | |
if (php_stream_mmap_possible(src)) { | |
char *p; | |
+ size_t mmap_max = PHP_STREAM_MMAP_MAX; | |
+ if (php_stream_is(dest, PHP_STREAM_IS_USERSPACE)) { | |
+ mmap_max = dest->chunk_size; | |
+ } | |
+ | |
do { | |
/* We must not modify maxlen here, because otherwise the file copy fallback below can fail */ | |
size_t chunk_size, must_read, mapped; | |
if (maxlen == 0) { | |
/* Unlimited read */ | |
- must_read = chunk_size = PHP_STREAM_MMAP_MAX; | |
+ must_read = chunk_size = mmap_max; | |
} else { | |
must_read = maxlen - haveread; | |
- if (must_read >= PHP_STREAM_MMAP_MAX) { | |
- chunk_size = PHP_STREAM_MMAP_MAX; | |
+ if (must_read >= mmap_max) { | |
+ chunk_size = mmap_max; | |
} else { | |
/* In case the length we still have to read from the file could be smaller than the file size, | |
* chunk_size must not get bigger the size we're trying to read. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment