Commit ec63cd6 for zlib
commit ec63cd60eb08454cb02795b7535206876b9ef96e
Author: Mark Adler <git@madler.net>
Date: Sun Sep 20 20:24:20 2026 -0700
Fix one more truncated stream detection bug.
This fixes a false negative that has been there since 1.2.4.
diff --git a/gzread.c b/gzread.c
index 1a9af4d..5641b3c 100644
--- a/gzread.c
+++ b/gzread.c
@@ -302,8 +302,11 @@ local int gz_skip(gz_statep state) {
}
/* output buffer empty -- return if we're at the end of the input */
- else if (state->eof && state->strm.avail_in == 0)
+ 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");
break;
+ }
/* need more data to skip -- load up output buffer */
else {
@@ -356,8 +359,11 @@ local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
}
/* output buffer empty -- return if we're at the end of the input */
- else if (state->eof && state->strm.avail_in == 0)
+ 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");
break;
+ }
/* need output data -- for small len or new stream load up our output
buffer, so that gzgetc() can be fast */