[ccache] ccache doesn't notice gzip CRC errors
Joel Rosdahl
joel at rosdahl.net
Sun Oct 31 11:48:05 MDT 2010
On 2010-10-29 03:54, Wilson Snyder wrote:
> 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!
> --- 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);
Why is the above gzeof call needed? The implementation doesn't seem to
modify the state and the documentation doesn't imply that it could.
> + 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);
Looks good otherwise.
-- Joel
More information about the ccache
mailing list