-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
The following unit test produces a Debug.Assert when using a Stream from opening a ZipFile and seeking past the end of the stream:
[Fact]
public void SeekPastEndAssert()
{
MemoryStream ms = new();
using (ZipArchive archive = new(ms, ZipArchiveMode.Create, leaveOpen: true)) {
ZipArchiveEntry entry = archive.CreateEntry("test.txt", CompressionLevel.NoCompression);
using (Stream stream = entry.Open()) {
stream.Write("Hello, World!"u8);
}
}
ms.Position = 0;
using ZipArchive readArchive = new(ms, ZipArchiveMode.Read);
using var readStream = readArchive.Entries[0].Open();
readStream.Seek(1, SeekOrigin.End);
byte[] buffer = new byte[1024];
readStream.Read(buffer, 0, buffer.Length);
}Fails with:
Error Message:
Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException : Method Debug.Fail failed with 'count >= 0',
and was translated to Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException to avoid terminating the process hosting the test.
Stack Trace:
at Microsoft.VisualStudio.TestPlatform.TestHost.TestHostTraceListener.GetException(String message)
at Microsoft.VisualStudio.TestPlatform.TestHost.TestHostTraceListener.Fail(String message, String detailMessage)
at System.Diagnostics.TraceInternal.Fail(String message, String detailMessage) in /source/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceInternal.cs:line 261
at System.Diagnostics.TraceInternal.TraceProvider.Fail(String message, String detailMessage) in /source/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceInternal.cs:line 17
at System.Diagnostics.Debug.Fail(String message, String detailMessage) in /source/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debug.cs:line 135
at System.Diagnostics.Debug.Assert(Boolean condition, String message, String detailMessage) in /source/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debug.cs:line 99
at System.Diagnostics.Debug.Assert(Boolean condition, String message) in /source/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debug.cs:line 88
at System.IO.Compression.SubReadStream.Read(Byte[] buffer, Int32 offset, Int32 count) in /source/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipCustomStreams.cs:line 339
at System.IO.Compression.Tests.ZipFile_Create.SeekPastEndAssert() in /source/src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Create.cs:line 33
at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) in /source/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs:line 1165
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args) in /source/src/coreclr/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.CoreCLR.cs:line 36
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) in /source/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs:line 57
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in /source/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs:line 134
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) in /source/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBase.cs:line 56
Multiple overloads of Read are likely impacted.
Reactions are currently unavailable