From 257186a86565a237b7bf264985efc784d50448be Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 17 May 2018 15:06:31 +1000 Subject: [PATCH] Fix zero sized archive decompression. --- runzip.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runzip.c b/runzip.c index 44e886d..f1a3d78 100644 --- a/runzip.c +++ b/runzip.c @@ -382,9 +382,11 @@ i64 runzip_fd(rzip_control *control, int fd_in, int fd_out, int fd_hist, i64 exp do { u = runzip_chunk(control, fd_in, expected_size, total); - if (unlikely(u < 1)) { - print_err("Failed to runzip_chunk in runzip_fd\n"); - return -1; + if (u < 1) { + if (u < 0 || total < expected_size) { + print_err("Failed to runzip_chunk in runzip_fd\n"); + return -1; + } } total += u; if (TMP_OUTBUF) {