Repository navigation
Conversation
Adds StreamExtensions.ReadFull and uses it for every data read (PFS signing and XTS in PfsBuilder.WriteImage(Stream), StreamReader, ReaderBase, PkgReader, header readers). PfsBuilder.WriteImage(Stream) now sizes the stream to the full image first, as the memory-mapped path does: standalone images (pfs_buildouter) previously encrypted stale bytes into the final sector. Test builds through a stream that returns <=1000 bytes per Read and requires byte-identical output.
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.
Several places assumed
Stream.Readfills the buffer. That is not guaranteed: it holds forMemoryStream/localFileStreamin practice, but not for network or wrapping streams.The important ones read data:
PfsBuilder.WriteImage(Stream);Util.StreamReader(used to read packages from streams).Adds
StreamExtensions.ReadFull, which reads exactlycountbytes or throwsEndOfStreamException, and uses it for every data/header read.PfsBuilder.WriteImage(Stream)now also sizes the stream to the full image first, as the memory-mapped path does. Previously a standalone image (pfs_buildouter) hit end-of-stream at the last block, and the reused sector buffer encrypted stale bytes into the final sector.Tests:
PartialReadTestsbuild a signed+encrypted image and a full PKG through a stream that returns at most 1000 bytes perRead, and require byte-identical output. Both fail on master.