From: Wilson Snyder Date: Mon, 1 Nov 2010 17:26:22 +0000 (+0100) Subject: Check for CRC errors after decompression X-Git-Tag: v3.1.1~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=87c78c9b299c2c543a93a66b7018332ae845892d;p=thirdparty%2Fccache.git Check for CRC errors after decompression --- 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);