check if second stream is zip header without changing position - fix

This commit is contained in:
Adam Hathcock
2026-01-22 15:06:58 +00:00
parent 65208a30c1
commit ae4f2c08fd

View File

@@ -41,9 +41,16 @@ public partial class ZipArchive : AbstractWritableArchive<ZipArchiveEntry, ZipVo
var idx = 0;
if (streams.Count() > 1)
{
streams[1].Position += 4;
var isZip = IsZipFile(streams[1], ReaderOptions.Password, ReaderOptions.BufferSize);
streams[1].Position -= 4;
//check if second stream is zip header without changing position
var headerProbeStream = streams[1];
var startPosition = headerProbeStream.Position;
headerProbeStream.Position = startPosition + 4;
var isZip = IsZipFile(
headerProbeStream,
ReaderOptions.Password,
ReaderOptions.BufferSize
);
headerProbeStream.Position = startPosition;
if (isZip)
{
stream.IsVolumes = true;