Commit f40786e for zlib
commit f40786e3fff851990a33ea31d506ef045b0bc129
Author: ronald.eytchison@trailofbits.com <ronald.eytchison@trailofbits.com>
Date: Fri Jun 5 19:10:16 2026 +0000
Clear gz skip when forced seek reaches EOF.
gz_skip() left the remaining skip in place when it reached the end
of the input, so gztell() reported the requested offset instead of
the end of the file after gzungetc(-1) forced a pending seek,
contrary to zlib.h. Clear the skip and note that the end of the
file was passed.
Reported by Trail of Bits (TOB-ZLIB-006).
diff --git a/gzread.c b/gzread.c
index b95dec6..b18f01b 100644
--- a/gzread.c
+++ b/gzread.c
@@ -315,6 +315,8 @@ local int gz_skip(gz_statep state) {
else if (state->eof && state->strm.avail_in == 0) {
if (state->how == GZIP && state->err == Z_OK)
gz_error(state, Z_BUF_ERROR, "unexpected end of file");
+ state->skip = 0;
+ state->past = 1;
break;
}