From 2a06f6709912991d0468cbec0db1d4f006a28481 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Thu, 9 Jan 2020 15:11:31 +0100 Subject: [PATCH] FIX: Decompressing lots of small files triggered error An archive containing lots of small files could trigger an error even though the amount of decompressed data was way below the maximum allowed size. This happened because the decompression algorithm used the chunk size for calculating the remaining size instead of the actual size of the decompressed chunk. --- lib/compression/strategy.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/compression/strategy.rb b/lib/compression/strategy.rb index 47151a3bf07..5e7088cc6c5 100644 --- a/lib/compression/strategy.rb +++ b/lib/compression/strategy.rb @@ -83,9 +83,8 @@ module Compression end ::File.open(entry_path, 'wb') do |os| - buf = ''.dup while (buf = entry.read(chunk_size)) - remaining_size -= chunk_size + remaining_size -= buf.size raise ExtractFailed if remaining_size.negative? os << buf end