Bug #74240 [NEW]: deflate_add can allocate too much memory
| From: | matt at bonneau dot net | Date: | Mon, 13 Mar 2017 03:43:39 +0000 |
| Subject: | Bug #74240 [NEW]: deflate_add can allocate too much memory | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-207809@lists.php.net to get a copy of this message | ||
From: matt at bonneau dot net
Operating system: All
PHP version: master-Git-2017-03-13 (Git)
Package: Zlib related
Bug Type: Bug
Bug description:deflate_add can allocate too much memory
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 bug report at https://bugs.php.net/bug.php?id=74240&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74240&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74240&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74240&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74240&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74240&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74240&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74240&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74240&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74240&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74240&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74240&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74240&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74240&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74240&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74240&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74240&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74240&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74240&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74240&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74240&r=mysqlcfg