Skip to content

Commit

Permalink
PBuild::Zip: fix decompression reading too many bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Jan 26, 2022
1 parent 98902d1 commit 5b6b915
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions PBuild/Zip.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ sub readbytes {
seek($handle, $pos, 0) || die("seek: $!\n") if defined($pos);
my $d;
my $r = read($handle, $d, $size);
die("read: $!\n") unless defined $r;
die("read: unexpeced EOF\n") unless $r == $size;
die("zip read: $!\n") unless defined $r;
die("zip read: unexpeced EOF ($r != $size)\n") unless $r == $size;
return $d;
}

Expand Down Expand Up @@ -61,6 +61,7 @@ sub extract_inflate {
die("unexpected EOF\n") unless $csize > 0;
my $chunksize = $csize > 65536 ? 65536 : $csize;
my $chunk = readbytes($handle, $chunksize);
$csize -= $chunksize;
my $infchunk = '';
($status) = $decomp->inflate($chunk, $infchunk);
die("decompression error\n") unless $status == Compress::Raw::Zlib::Z_OK() || $status == Compress::Raw::Zlib::Z_STREAM_END();
Expand Down

0 comments on commit 5b6b915

Please sign in to comment.