Skip to content

Zip64ExtraField should read StartDiskNumber as uint32 #31825

Closed

Description

@eerhardt

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

Activity

  1. added
    untriaged
    on Feb 5, 2020
  2. added this to the Future milestone on Jun 29, 2020
  3. removed
    untriaged
    on Jul 8, 2020
  4. added
    good first issue
    help wanted
    on Dec 10, 2021
  5. ghost added
    in-pr
    on Dec 17, 2021
  6. ghost removed
    in-pr
    on Jul 22, 2022
  7. added a commit that references this issue on Mar 25, 2023
    c538535
  8. ghost added
    in-pr
    on Mar 25, 2023
  9. antara-gandhi commented on Mar 29, 2023

    @antara-gandhi

    hi there! @eerhardt is this issue still open?

  10. eerhardt commented on Mar 29, 2023

    @eerhardt
    MemberAuthor

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

  11. ghost removed
    in-pr
    on May 19, 2023
  12. ghost added
    in-pr
    on May 19, 2023
  13. added a commit that references this issue on Jun 1, 2023
    7bcd509
  14. ghost removed
    in-pr
    on Jun 1, 2023
  15. modified the milestones: Future, 8.0.0 on Jun 1, 2023
  16. ghost locked as resolved and limited conversation to collaborators on Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.IO.Compressiongood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions