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

fix: Always return an error or some content from LimitedReader #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

secDre4mer
Copy link
Contributor

The contract from io.ReaderAt requires that err != nil if less
than len(p) bytes are returned, and that 0 <= n <= len(p).
LimitedReader currently fulfills neither requirements:

  • For off > self.N, n is negative.
  • For off + n > self.N, n is limited and thus n < len(p),
    but no error is returned.

Add additional cases to catch these contract violations.

The contract from io.ReaderAt requires that err != nil if less
than len(p) bytes are returned, and that 0 <= n <= len(p).
LimitedReader currently fulfills neither requirements:
 - For off > self.N, n is negative.
 - For off + n > self.N, n is limited and thus n < len(p),
   but no error is returned.

Add additional cases to catch these contract violations.
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