about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-03-21T18·20+0100
committerEelco Dolstra <edolstra@gmail.com>2017-03-21T18·23+0100
commited5c0f69f28732879a7aac2d67367446f6d3152d (patch)
tree99878e6b1e62c9d77158468a7d6aa0a7cb17b82b
parentaa23bba27f402913a7cfa7854b5d3b6ddf321e74 (diff)
Don't hang in decompression if bzip2 data ends prematurely
-rw-r--r--src/libutil/compression.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libutil/compression.cc b/src/libutil/compression.cc
index 8ffd55efb23c..11eec7a7bc20 100644
--- a/src/libutil/compression.cc
+++ b/src/libutil/compression.cc
@@ -49,6 +49,9 @@ static ref<std::string> 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<std::string> 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");
     }
 }