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) {