Subject: | Z_OK instead of Z_BUF_ERROR |
Hi,
It looks like LimitOutput in Compress::Raw::Zlib::Inflate does not work correctly and inflate() keeps returning Z_OK instead of Z_BUF_ERROR. Here's a script that demonstrates the problem.
use Compress::Raw::Zlib qw(Z_OK Z_BUF_ERROR Z_SYNC_FLUSH);
# 1M "aaa..."
my $in = 'a' x 1000000;
my $deflate
= Compress::Raw::Zlib::Deflate->new(WindowBits => -15, MemLevel => 8);
$deflate->deflate($in, my $zip);
$deflate->flush($zip, Z_SYNC_FLUSH);
# Compression should stop after 10K "aaa..." with Z_BUF_ERROR
my $inflate = Compress::Raw::Zlib::Inflate->new(
Bufsize => 10000,
LimitOutput => 1,
WindowBits => -15
);
my $status = $inflate->inflate($zip, my $out);
warn 'RESULT: ', length($out), ' of ', length($in), "\n";
warn "OK\n" if $status == Z_OK;
warn "BUFFER ERROR\n" if $status == Z_BUF_ERROR;
I'd also be very interested if there's a temporary workaround, since having your WebSocket server vulnerable to zip bombs is not particularly nice.
--
sebastian