runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Zip64ExtraField should read StartDiskNumber as uint32

Open eerhardt opened this issue 6 years ago • 2 comments

According to https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT:

4.4.1 General notes on fields

 4.4.1.1  All fields unless otherwise noted are unsigned and stored
 in Intel low-byte:high-byte, low-word:high-word order.

And the spec for the Zip64ExtraField doesn't note otherwise:

4.5.3 -Zip64 Extended Information Extra Field (0x0001):

   Disk Start
   Number     4 bytes    Number of the disk on which
                         this file starts 

However, we are reading the "Disk Start Number" as a signed int32, and then throwing an exception if the number is negative:

https://github.com/dotnet/runtime/blob/33b7ed8795d70d28bfeaf40498d94f6bede8769d/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs#L209-L218

We should change this to zip64Block._startDiskNumber = reader.ReadUInt32();, remove the exception, and flow the uint value everywhere.

Looking at the reference source:

https://referencesource.microsoft.com/#WindowsBase/Base/MS/Internal/IO/Zip/ZipIOExtraFieldZip64Element.cs,101

That is reading as uint32 as well. We should update to the same.

Here is a prototype of the change: https://github.com/eerhardt/runtime/commit/b790a945d9adbddbdf8caff4e75c8e9e33682533

eerhardt avatar Feb 05 '20 21:02 eerhardt

hi there! @eerhardt is this issue still open?

antara-gandhi avatar Mar 29 '23 02:03 antara-gandhi

Yes it is still open, but it looks like there is an active PR that will fix it - https://github.com/dotnet/runtime/pull/83923.

eerhardt avatar Mar 29 '23 15:03 eerhardt