Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Zlib::GzipReader#eof? check if we're actually at eof #72

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

martinemde
Copy link
Contributor

@martinemde martinemde commented Dec 22, 2023

When checking for eof?, read ahead until we can confidently say that either there is more content or the stream is finished. If reading ahead fills the z->buf, we are not at eof.

It's possible that only empty blocks or the footer remain to be read from the input stream. If eof? is only based on current status of the stream, a following read may produce no output, causing an EOFError because there's nothing left to return. This only happens for very specific gzip file lengths that hit exactly at a modulo of the read size, leaving only empty blocks and the footer remaining to be read.

Fixes #56

Only consider it eof if we read ahead and something fills the buf.
If not, we may only have empty blocks and the footer.

Fixes ruby#56
@nobu nobu merged commit 78658aa into ruby:master Feb 22, 2024
1 check passed
@martinemde
Copy link
Contributor Author

@nobu thank you 🙇‍♂️

@martinemde martinemde deleted the martinemde/readpartial-fix branch February 22, 2024 16:48
k0kubun pushed a commit that referenced this pull request May 29, 2024
In Zlib::GzipReader#eof? check if we're actually at eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Zlib::GzipReader#readpartial until eof? causes EOFError
2 participants