Skip to content

Fix AlignedStream read to EOF when not aligned - #137

Open
alan-divd wants to merge 1 commit into
fox-it:mainfrom
alan-divd:fix/alignedstream-read-no-size
Open

alan-divd wants to merge 1 commit into
fox-it:mainfrom
alan-divd:fix/alignedstream-read-no-size

Conversation

@alan-divd

Copy link
Copy Markdown

Summary

AlignedStream.read() with no size reads from the aligned offset rather than
the current position, so it returns the wrong bytes and leaves tell() past
the real end of the stream.

This is visible through RelativeStream, which documents support for reading
without a size. On a 32 byte stream, seek(10) followed by read() returns
32 bytes starting at offset 0 instead of the 22 bytes from offset 10, and
tell() ends up at 42.

Slice the leading bytes off the aligned read so both the buffered and
unbuffered paths return data from the current position, and track the final
position from what was actually returned.

Found while fixing #114, and filed separately since it is a distinct bug in
the base class rather than in OverlayStream.

Fixes #135

Test plan

  • tox run -e py3 passes (160 passed)
  • Exercises both the freshly-seeked and already-buffered paths through
    the public RelativeStream API

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.

AlignedStream read without a size reads from the wrong position

1 participant