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 SlicedStream.Seek(offset, SeekOrigin.End) #18313

Merged
merged 2 commits into from
Feb 26, 2025

Conversation

pjt33
Copy link
Contributor

@pjt33 pjt33 commented Feb 25, 2025

This fixes #13604

The offset _from is applied in set_Position, so applying it also in Seek mispositions the stream. ZipArchive exposes the problem by seeking to the end to read the table of contents.

What does the pull request do?

Fixes a double-offset in SlicedStream which should only be a single offset. Resolves #13604

What is the current behavior?

SlicedStream.Seek(offset, SeekOrigin.End) will almost always seek to an incorrect position.

What is the updated/expected behavior with this PR?

After calling stream.Seek(offset, SeekOrigin.End) it will be the case that stream.Position == stream.Length + offset).

How was the solution implemented (if it's not obvious)?

Remove an offset in Seek which is also applied when Seek calls set_Position. Note that this was only incorrect for SeekOrigin.End: for SeekOrigin.Begin and SeekOrigin.Current the offset was (correctly) not applied.

Checklist

Fixed issues

Fixes #13604

This fixes AvaloniaUI#13604

The offset _from is applied in set_Position, so applying it also in Seek mispositions the stream. ZipArchive exposes the problem by seeking to the end to read the table of contents.
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0055141-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@cla-avalonia
Copy link
Collaborator

cla-avalonia commented Feb 25, 2025

  • All contributors have signed the CLA.

@pjt33
Copy link
Contributor Author

pjt33 commented Feb 25, 2025

@cla-avalonia agree

@MrJul MrJul added the bug label Feb 26, 2025
Copy link
Member

@MrJul MrJul left a comment

Choose a reason for hiding this comment

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

LGTM, thank you! I took the liberty of adding some related unit tests (we had none for SlicedStream).

@MrJul MrJul enabled auto-merge February 26, 2025 10:38
@maxkatz6 maxkatz6 added the backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch label Feb 26, 2025
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0055163-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul added the backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch label Feb 26, 2025
@MrJul MrJul added this pull request to the merge queue Feb 26, 2025
Merged via the queue into AvaloniaUI:master with commit 11b5d42 Feb 26, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unable to decompress a stream from assets
5 participants