From ed5c0f69f28732879a7aac2d67367446f6d3152d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 21 Mar 2017 19:20:21 +0100 Subject: Don't hang in decompression if bzip2 data ends prematurely --- src/libutil/compression.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/libutil/compression.cc b/src/libutil/compression.cc index 8ffd55efb..11eec7a7b 100644 --- a/src/libutil/compression.cc +++ b/src/libutil/compression.cc @@ -49,6 +49,9 @@ static ref decompressXZ(const std::string & in) if (ret != LZMA_OK) throw Error("error while decompressing xz file"); + + if (strm.avail_in == 0) + throw Error("xz data ends prematurely"); } } @@ -86,6 +89,9 @@ static ref decompressBzip2(const std::string & in) if (ret != BZ_OK) throw Error("error while decompressing bzip2 file"); + + if (strm.avail_in == 0) + throw Error("bzip2 data ends prematurely"); } } -- cgit v1.2.3