#34821 [Fbk->Opn]: zlib encoders fail on widely varying binary data
| From: | mike@php.net | Date: | Tue, 11 Oct 2005 17:03:44 +0000 |
| Subject: | #34821 [Fbk->Opn]: zlib encoders fail on widely varying binary data | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-86424@lists.php.net to get a copy of this message | ||
ID: 34821
Updated by: mike@php.net
Reported By: mike@php.net
-Status: Feedback
+Status: Open
Bug Type: Zlib Related
Operating System: *
PHP Version: *
New Comment:
http://dev.iworks.at/PATCHES/bug_34821.txt
Previous Comments:
------------------------------------------------------------------------
[2005-10-11 18:43:31] tony2001@php.net
Do you have a patch?
------------------------------------------------------------------------
[2005-10-11 17:38:00] mike@php.net
A possible fix would be to raise the size of the memory allocated by
default, e.g. adding 1% to the length of the incoming data instead of
0.1% additionally to some "safe" padding bytes.
------------------------------------------------------------------------
[2005-10-10 22:50:22] mike@php.net
Description:
------------
Probably an edge case, but so nobody could claim I didn't report it ;)
It starts to fail with ~200k+.
Reproduce code:
---------------
<?php
$j = 200000;
$s = '';
srand(time());
for ($i = 0; $i < $j; ++$i) {
$s .= chr(rand(0,255));
}
gzencode($s); // fails with buffer error
$r = array();
echo "\nCharcode stats:\n";
for ($i = 0; $i < $j; ++$i) {
$x = ord($s{$i});
$r[$x] = isset($r[$x]) ? $r[$x]+1 : 1;
}
asort($r);
printf("MIN: %d -- AVG: %d -- MAX: %d\n", current($r),
array_sum($r)/count($r), end($r));
?>
Expected result:
----------------
No error
Actual result:
--------------
Warning: gzencode(): buffer error in
C:\Webserver\mike\zone\gzencode.php on line 10
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34821&edit=1