Uh oh!
There was an error while loading. Please reload this page.
Use Stream.ReadAtLeast when loading ZipArchives - #114256
Conversation
Tagging subscribers to this area: @dotnet/area-system-io-compression |
carlossanlop
left a comment
There was a problem hiding this comment.
Thanks for this change, @edwardneal. I left some comments/questions for you to consider.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
carlossanlop
left a comment
There was a problem hiding this comment.
LGTM modulo the debug question.
carlossanlop
commented
Apr 14, 2025
/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