From 87c78c9b299c2c543a93a66b7018332ae845892d Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 1 Nov 2010 18:26:22 +0100 Subject: [PATCH] Check for CRC errors after decompression --- util.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/util.c b/util.c index a0ffb45a9..ae1600698 100644 --- a/util.c +++ b/util.c @@ -260,7 +260,13 @@ copy_file(const char *src, const char *dest, int compress_dest) goto error; } } - if (n == 0 && !gzeof(gz_in)) { + + /* + * gzeof won't tell if there's an error in the trailing CRC, so we must check + * gzerror before considering everything OK. + */ + gzerror(gz_in, &errnum); + if (!gzeof(gz_in) || (errnum != Z_OK && errnum != Z_STREAM_END)) { cc_log("gzread error: %s (errno: %s)", gzerror(gz_in, &errnum), strerror(errno)); gzclose(gz_in); -- 2.47.3