#34821 [Opn->Fbk]: zlib encoders fail on widely varying binary data
| From: | iliaa@php.net | Date: | Thu, 13 Oct 2005 17:05:23 +0000 |
| Subject: | #34821 [Opn->Fbk]: zlib encoders fail on widely varying binary data | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-86552@lists.php.net to get a copy of this message | ||
ID: 34821
Updated by: iliaa@php.net
Reported By: mike@php.net
-Status: Open
+Status: Feedback
Bug Type: Zlib Related
Operating System: *
PHP Version: 5CVS-2005-10-10 (cvs)
New Comment:
I've just tried the code on Linux using 5.1-cvs and I am not seeing any
errors being reported.
Previous Comments:
------------------------------------------------------------------------
[2005-10-11 19:03:43] mike@php.net
http://dev.iworks.at/PATCHES/bug_34821.txt
------------------------------------------------------------------------
[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