note 94325 deleted from function.gzinflate by danbrown
| From: | danbrown@php.net | Date: | Thu, 29 Oct 2009 00:35:17 +0000 |
| Subject: | note 94325 deleted from function.gzinflate by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162216@lists.php.net to get a copy of this message | ||
Note Submitter: vitall at ua dot fm
----
Upgrade decode_gzip function, see below.
The Data can be damaged and other some moments.
In the same way in functions gzinflate there is Bug which is removed only in the most modern php
version.
<?php
function decode_gzip($h,$d,$rn="\r\n"){
if (isset($h['Transfer-Encoding'])){
$lrn = strlen($rn);
do{
@$p = strpos($d,$rn,$ofs);
if($p===false){$str=''; break;}
$len = hexdec(substr($d,$ofs,$p-$ofs));
$str .= substr($d,$p+$lrn,$len);
$ofs = $p+$lrn*2+$len;
}while ($d[$ofs]!=='0');
$d=$str;
}
//$slupd = unpack('L',substr($d,-4));
if (isset($h['Content-Encoding']))
{
static $lim_mem;
if(!$lim_mem) $lim_mem = ini_get('memory_limit')<<18;
@$d = gzinflate(substr($d,10),$lim_mem);
}
return $d;
}
?>