aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorEA117 <admin@ea117.com>2019-08-26 21:07:01 -0500
committerEA117 <admin@ea117.com>2019-08-26 21:07:01 -0500
commit4cdfb3f4eddb1c3ccaa304b1c8d3fade7e18f75e (patch)
tree18045ab66f957e9b8ccc1e7c2cb8e3efb27350fa /phpBB
parent9c15594fe498a8a1640bb89aa0c93800918a9798 (diff)
downloadforums-4cdfb3f4eddb1c3ccaa304b1c8d3fade7e18f75e.tar
forums-4cdfb3f4eddb1c3ccaa304b1c8d3fade7e18f75e.tar.gz
forums-4cdfb3f4eddb1c3ccaa304b1c8d3fade7e18f75e.tar.bz2
forums-4cdfb3f4eddb1c3ccaa304b1c8d3fade7e18f75e.tar.xz
forums-4cdfb3f4eddb1c3ccaa304b1c8d3fade7e18f75e.zip
[ticket/16141] plupload chunk_size incorrect when 'unlimited' is involved.
Change get_chunk_size() calculation to correctly calculate limits without letting a zero "unlimited" value always win. Also ensure get_chunk_size() can only return zero if all of the limits were in fact set to unlimited. PHPBB3-16141
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/phpbb/plupload/plupload.php52
1 files changed, 44 insertions, 8 deletions
diff --git a/phpBB/phpbb/plupload/plupload.php b/phpBB/phpbb/plupload/plupload.php
index eb698fb35d..ac4811e4ef 100644
--- a/phpBB/phpbb/plupload/plupload.php
+++ b/phpBB/phpbb/plupload/plupload.php
@@ -283,15 +283,51 @@ class plupload
*/
public function get_chunk_size()
{
- $max = min(
- $this->php_ini->getBytes('upload_max_filesize'),
- $this->php_ini->getBytes('post_max_size'),
- max(1, $this->php_ini->getBytes('memory_limit')),
- $this->config['max_filesize']
- );
+ $max = 0;
+
+ $limit = $this->php_ini->getBytes('memory_limit');
+
+ // unlimited is -1 for memory_limit. 0 would be an invalid configuration.
+
+ if ($limit > 0)
+ {
+ $max = $limit;
+ }
+
+ // For all remaining limits, 0 means "unlimited".
+
+ // For each limit, if there is a non-unlimited value to
+ // apply, apply the limit if it's less than whatever non-
+ // unlimited max value is currently set. Also, apply the
+ // limit if the current max value is otherwise unlimited.
+
+ $limit = $this->php_ini->getBytes('upload_max_filesize');
+
+ if ($limit > 0)
+ {
+ $max = min($limit, max($max, $limit));
+ }
+
+ $limit = $this->php_ini->getBytes('post_max_size');
+
+ if ($limit > 0)
+ {
+ $max = min($limit, max($max, $limit));
+ }
+
+ $limit = $this->config['max_filesize'];
+
+ if ($limit > 0)
+ {
+ $max = min($limit, max($max, $limit));
+ }
+
+ // Only if every limit was 0/unlimited will we still
+ // have a zero value in $max at this point.
+
+ // Use half of the maximum possible to leave plenty of
+ // room for other POST data and be well under limits.
- // Use half of the maximum possible to leave plenty of room for other
- // POST data.
return floor($max / 2);
}