GZIP files contain CRC checksums, however ccache doesn't
notice CRC errors because it doesn't check gzerror at the
end of decompression.  This patch fixes it.  (It's arguably
a bad API decision on the gz library's part, but we're stuck
with it.)

Thanks

diff --git a/util.c b/util.c
index 58723f0..f2ad77c 100644
--- a/util.c
+++ b/util.c
@@ -284,7 +284,12 @@ 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 must gzeof then test gzerror before considering everything ok */
+       gzeof(gz_in);
+       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);

_______________________________________________
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache

Reply via email to