Skip to content

Conversation

@scunningham
Copy link
Contributor

Offsets on the read progress callback were misaligned.

  • Did not account for the header size on the Read() case.
  • Did not account for block header size (and possibly blk checksum) in the uncompressable case.

@scunningham scunningham requested a review from aleksmaus January 23, 2025 15:07
Copy link

@aleksmaus aleksmaus left a comment

Choose a reason for hiding this comment

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

Left one question. Otherwise looks ok.

_, err := r._readHeader()
n, err := r._readHeader()

r.srcPos += int64(n)

Choose a reason for hiding this comment

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

doing this before error check, is this correct?

Copy link
Contributor Author

@scunningham scunningham Jan 23, 2025

Choose a reason for hiding this comment

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

Yeah, in general supposed to accept bytes before processing error. From io.Reader

Callers should always process the n > 0 bytes returned before considering the error err. Doing so correctly handles I/O errors that happen after reading some bytes and also both of the allowed EOF behaviors.

In practice it won't matter in this case because the call will error out and the reader will be in an error state.

@scunningham scunningham merged commit b987b5c into main Jan 23, 2025
6 checks passed
@scunningham scunningham deleted the progress_bug branch January 23, 2025 15:25
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.

3 participants