Skip to content

Zip64ExtraField should read StartDiskNumber as uint32 #31825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #62658
eerhardt opened this issue Feb 5, 2020 · 2 comments · Fixed by #83923
Closed
Tracked by #62658

Zip64ExtraField should read StartDiskNumber as uint32 #31825

eerhardt opened this issue Feb 5, 2020 · 2 comments · Fixed by #83923
Labels
area-System.IO.Compression good first issue Issue should be easy to implement, good for first-time contributors help wanted [up-for-grabs] Good issue for external contributors
Milestone

Comments

@eerhardt
Copy link
Member

eerhardt commented Feb 5, 2020

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:

if (readUncompressedSize) zip64Block._uncompressedSize = reader.ReadInt64();
if (readCompressedSize) zip64Block._compressedSize = reader.ReadInt64();
if (readLocalHeaderOffset) zip64Block._localHeaderOffset = reader.ReadInt64();
if (readStartDiskNumber) zip64Block._startDiskNumber = reader.ReadInt32();
// original values are unsigned, so implies value is too big to fit in signed integer
if (zip64Block._uncompressedSize < 0) throw new InvalidDataException(SR.FieldTooBigUncompressedSize);
if (zip64Block._compressedSize < 0) throw new InvalidDataException(SR.FieldTooBigCompressedSize);
if (zip64Block._localHeaderOffset < 0) throw new InvalidDataException(SR.FieldTooBigLocalHeaderOffset);
if (zip64Block._startDiskNumber < 0) throw new InvalidDataException(SR.FieldTooBigStartDiskNumber);

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: eerhardt@b790a94

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Feb 5, 2020
@carlossanlop carlossanlop added this to the Future milestone Jun 29, 2020
@carlossanlop carlossanlop removed the untriaged New issue has not been triaged by the area owner label Jul 8, 2020
@danmoseley danmoseley added good first issue Issue should be easy to implement, good for first-time contributors help wanted [up-for-grabs] Good issue for external contributors labels Dec 10, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Dec 17, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 22, 2022
mruslan97 pushed a commit to mruslan97/runtime that referenced this issue Mar 25, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Mar 25, 2023
@antara-gandhi
Copy link

hi there! @eerhardt is this issue still open?

@eerhardt
Copy link
Member Author

Yes it is still open, but it looks like there is an active PR that will fix it - #83923.

@ghost ghost added in-pr There is an active PR which will close this issue when it is merged and removed in-pr There is an active PR which will close this issue when it is merged labels May 19, 2023
adamsitnik pushed a commit that referenced this issue Jun 1, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jun 1, 2023
@adamsitnik adamsitnik modified the milestones: Future, 8.0.0 Jun 1, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.IO.Compression good first issue Issue should be easy to implement, good for first-time contributors help wanted [up-for-grabs] Good issue for external contributors
Projects
None yet
6 participants