Skip to content

Fix "G" (gzip only) after gzrewind() - #1423

Open
UOS-liang wants to merge 1 commit into
madler:developfrom
UOS-liang:gzip-only-after-rewind
Open

UOS-liang wants to merge 1 commit into
madler:developfrom
UOS-liang:gzip-only-after-rewind

Conversation

@UOS-liang

Copy link
Copy Markdown

A file without a gzip header was read as plain bytes after gzrewind() on a handle opened with "rbG", although "G" must return an error when there is no gzip header. gzdirect() or any other call that inspects the file before the rewind triggers it; a backwards gzseek() rewinds too.

gz_look() cleared state->direct, including the -1 set by "G". gzrewind() does not restore it, so the next gz_look() auto-detected the input and copied it instead of requiring a gzip header.

Keep direct at -1 when looking for a gzip member in gzip-only mode. Add a test that opens a file without a gzip header with "rbG", calls gzdirect() and gzrewind(), and requires gzread() to fail.

gz_look() cleared state->direct when it found a gzip header, including when
"G" had set it to -1.  gzrewind() does not reset direct, so the next
gz_look() auto-detected the input, and a handle opened with "G" copied a
file without a gzip header instead of failing.

Keep direct at -1 when looking for a gzip member in gzip-only mode.  Add a
test which opens a file without a gzip header with "rbG", calls gzdirect()
and gzrewind(), then checks that gzread() fails.

Fixes: madler#1380
Signed-off-by: Hailiang Ma <mahailiang@uniontech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant