Bug #74240 [Opn->Csd]: deflate_add can allocate too much memory
| From: | bwoebi@php.net | Date: | Tue, 14 Mar 2017 23:08:51 +0000 |
| Subject: | Bug #74240 [Opn->Csd]: deflate_add can allocate too much memory | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207840@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74240&edit=1
ID: 74240
Updated by: bwoebi@php.net
Reported by: matt at bonneau dot net
Summary: deflate_add can allocate too much memory
-Status: Open
+Status: Closed
Type: Bug
Package: Zlib related
Operating System: All
PHP Version: master-Git-2017-03-13 (Git)
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of matt@bonneau.net
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7fba8bda4c9e89c522e5d27a38489125e36b9904
Log: Fixed bug #74240 (deflate_add can allocate too much memory)
Previous Comments:
------------------------------------------------------------------------
[2017-03-13 03:43:36] matt at bonneau dot net
Description:
------------
deflate_add can grossly overestimate memory needed for the output buffer. This is more likely with
highly compressable data. The allocations are roughly equal to the total bytes processed by
deflate_add and can cause PHP to run out of memory.
Test script:
---------------
$deflator = deflate_init(ZLIB_ENCODING_RAW);
$bytes = str_repeat("*", 65536);
// if you use random bytes this usually can run forever
// because they are not very compressable
//$bytes = openssl_random_pseudo_bytes(65536);
// this crashes after about 500 iterations if PHP is
// configured for 64M
for ($i = 0; $i < 100000; $i++) {
echo "$i\n";
$output = deflate_add(
$deflator,
$bytes,
ZLIB_SYNC_FLUSH
);
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74240&edit=1