Repository navigation
stream_libarchive: don't corrupt the stream position on a failed seek - #18795
Merged
Merged
Conversation
archive_seek_data() returns the new position as la_int64_t. Fixes seeking > 2 GiB to not read everything from start.
The skip callback may skip less than requested, so bound the request by what the position can hold.
The stream layer keeps its buffer and s->pos when the seek callback fails, but archive_entry_seek() moved s->pos while reopening the archive and while reading forward. After a failed seek stream_tell() reported an offset unrelated to the buffered data. Track the entry position locally and let the stream layer set s->pos after a successful seek only.
The seek callback is documented to return ARCHIVE_FAILED when the seek failed without moving the read position and ARCHIVE_FATAL for any other error.
Entry names in a legacy codepage arrive from libarchive as raw bytes and were replaced by mpv_unknown#N when they weren't valid UTF-8. Run them through the mp_charset_guess(). libarchive's UTF-8 form of a name is used only when the plain form is missing. On Windows that is the case for Unicode names the C locale can't represent, while for raw names the UTF-8 form was a Latin-1 decode of the bytes, which hid them from any detection. Names that are valid UTF-8 are never recoded, so a forced codepage applies to the raw ones only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.