]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Check for CRC errors after decompression
authorWilson Snyder <wsnyder@wsnyder.org>
Mon, 1 Nov 2010 17:26:22 +0000 (18:26 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 1 Nov 2010 17:31:35 +0000 (18:31 +0100)
util.c

diff --git a/util.c b/util.c
index a0ffb45a910fb015eaee76d42ecfa879c7d1c86f..ae1600698b44f9b149315ea55fb1259a24e36d26 100644 (file)
--- 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);