go-ntfs icon indicating copy to clipboard operation
go-ntfs copied to clipboard

fix: Always return an error or some content from LimitedReader

Open secDre4mer opened this issue 3 years ago • 0 comments

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.

secDre4mer avatar Jun 07 '21 15:06 secDre4mer