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

reader: fix Skip(n) where n >= buffer size #22

Merged
merged 1 commit into from
Nov 24, 2020
Merged

reader: fix Skip(n) where n >= buffer size #22

merged 1 commit into from
Nov 24, 2020

Conversation

philhofer
Copy link
Owner

The (*Reader).Skip() code did not handle skip sizes
above the buffer size correctly, because the inner
reader loop only looped while 'r.buffered() < n', and
that condition is obviously violated when the reader
successfully buffers more bytes than are to be skipped.

Refactor this method to be a little shorter and hopefully
much clearer (and more correct) and add test coverage that
exercises this code better.

Fixes #20

The (*Reader).Skip() code did not handle skip sizes
above the buffer size correctly, because the inner
reader loop only looped while 'r.buffered() < n', and
that condition is obviously violated when the reader
successfully buffers more bytes than are to be skipped.

Refactor this method to be a little shorter and hopefully
much clearer (and more correct) and add test coverage that
exercises this code better.
Copy link

@klauspost klauspost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed to fix the issue with the fuzz test used to find the issue.

@philhofer philhofer merged commit 9bcb9ca into master Nov 24, 2020
klauspost added a commit to klauspost/minio that referenced this pull request Nov 24, 2020
The error in `github.com/philhofer/fwd` was quickly fixed through philhofer/fwd#22 - update the dependency and remove the workaround.
harshavardhana pushed a commit to minio/minio that referenced this pull request Nov 24, 2020
The error in `github.com/philhofer/fwd` was quickly fixed through 
philhofer/fwd#22 - update the dependency 
and remove the workaround.
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.

Big skips can fail with io.ErrNoProgress
2 participants