-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Use Stream.ReadAtLeast when loading ZipArchives
#114256
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
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-io-compression |
carlossanlop
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this change, @edwardneal. I left some comments/questions for you to consider.
src/libraries/System.IO.Compression/tests/ZipArchive/zip_ReadTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Compression/tests/System.IO.Compression.Tests.csproj
Show resolved
Hide resolved
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs
Show resolved
Hide resolved
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs
Show resolved
Hide resolved
src/libraries/System.IO.Compression/tests/Utilities/ClampedReadStream.cs
Show resolved
Hide resolved
src/libraries/System.IO.Compression/tests/ZipArchive/zip_ReadTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs
Outdated
Show resolved
Hide resolved
carlossanlop
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo the debug question.
|
/ba-g runtime-libraries-coreclr outerloop |
Fixes #114026. Swaps references to
Stream.Readout withStream.ReadAtLeast, adds a test to prove the correct behaviour.In every case except for ZipArchive, we use a pattern of calling
Stream.ReadAtLeast(Span, Span.Length, throwOnEndOfStream: false)rather thanStream.ReadExactly(Span). The surrounding code checks the number of bytes read and returns false, and I didn't want to change that pattern.The ZipArchive case takes place when reading the central directory, and it makes sure to always read enough bytes for the constant component of a ZipCentralDirectoryFileHeader.
/cc @carlossanlop