summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-12-23 13:52:24 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2020-12-23 13:52:45 +0100
commit7d9ddd61ecc2c99be8709cfa6b51e716343ad5da (patch)
treef8d5bcb15b3da44ac1a4061962a17b4867a0a3a0 /tests
parent288332077fa22b78afda1951a357444a901a9da9 (diff)
parent70dfbe00684eb1c31d5b49f643e4736696c3b7df (diff)
downloadphp-git-7d9ddd61ecc2c99be8709cfa6b51e716343ad5da.tar.gz
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix #80384: limit read buffer size
Diffstat (limited to 'tests')
-rw-r--r--tests/basic/bug80384.phpt28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/basic/bug80384.phpt b/tests/basic/bug80384.phpt
new file mode 100644
index 0000000000..cf30e8601b
--- /dev/null
+++ b/tests/basic/bug80384.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #80384 large reads cause filters to internally buffer large amounts of memory
+--FILE--
+<?php
+/* First, create a file to read */
+$tmp_filename = __DIR__ . "/bug80384.tmp";
+$fp = fopen($tmp_filename, 'w');
+for ($i=0; $i<1024; $i++) {
+ fwrite($fp, str_repeat('ABCDEFGH', 1024));
+}
+fclose($fp);
+
+/* Stream the file through a filter */
+$fp = fopen($tmp_filename, 'r');
+$filter = stream_filter_append($fp, "string.rot13");
+
+$mem_start = memory_get_usage();
+fread($fp, 8 * 1024 * 1024);
+$mem_final = memory_get_usage();
+fclose($fp);
+var_dump($mem_final - $mem_start < 32768);
+?>
+--CLEAN--
+<?php
+unlink(__DIR__ . "/bug80384.tmp");
+?>
+--EXPECT--
+bool(true)