Describe the bug
ZipArchiveEntry.cs incorrectly assumes that constructing a MemoryStream with a negative length is "okay" (see ZipArchiveEntry.GetCompressedData) The reality is that the MemoryStream constructor now throws an ArgumentOutOfRangeException (here) when an unchecked cast causes an uint to wrap around.
This appears to be new to netcore (versus netframework), and does cause unexpected failures where none had previously existed.
To Reproduce
Call ZipArchiveEntry.Open on a very large entry (> int.MaxValue).
Exceptions (if any)
ArgumentOutOfRangeException is thrown from the MemoryStream constructor.
Further technical details
This is no longer true -
<ZipArchiveEntry.cs>
// if _uncompressedSize > int.MaxValue, it's still okay, because MemoryStream will just
// grow as data is copied into it
_storedUncompressedData = new MemoryStream((int)_uncompressedSize);
<MemoryStream.cs>
public MemoryStream(int capacity)
{
ArgumentOutOfRangeException.ThrowIfNegative(capacity);
ArgumentOutOfRangeException.ThrowIfGreaterThan(capacity, MemStreamMaxLength);
Describe the bug
ZipArchiveEntry.csincorrectly assumes that constructing aMemoryStreamwith a negative length is "okay" (see ZipArchiveEntry.GetCompressedData) The reality is that theMemoryStreamconstructor now throws anArgumentOutOfRangeException(here) when an unchecked cast causes anuintto wrap around.This appears to be new to
netcore(versusnetframework), and does cause unexpected failures where none had previously existed.To Reproduce
Call
ZipArchiveEntry.Openon a very large entry (> int.MaxValue).Exceptions (if any)
ArgumentOutOfRangeExceptionis thrown from theMemoryStreamconstructor.Further technical details
This is no longer true -