Skip to content

Read StartDiskNumber as uint32 - #83923

Merged
adamsitnik merged 1 commit into
dotnet:mainfrom
mruslan97:issue-31825
Jun 1, 2023
Merged

adamsitnik merged 1 commit into
dotnet:mainfrom
mruslan97:issue-31825

Conversation

@mruslan97

Copy link
Copy Markdown
Contributor
  • The startDiskNumber field has been changed according to the zip specification.
  • Added test with the archive where the value of startDiskNumber greater than int.MaxValue.

Fix #31825

@ghost ghost added area-System.IO.Compression community-contribution Indicates that the PR has been added by a community member labels Mar 25, 2023
@ghost

ghost commented Mar 25, 2023

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

Issue Details
  • The startDiskNumber field has been changed according to the zip specification.
  • Added test with the archive where the value of startDiskNumber greater than int.MaxValue.

Fix #31825

Author: mruslan97
Assignees: -
Labels:

area-System.IO.Compression

Milestone: -

@danmoseley danmoseley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me except couple things

0x00, 0x00
};

private static readonly byte[] s_zip64WithBigStartDiskNumber =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than duplicate this whole thing what about just flipping the byte you need, within the test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, i'll try. But I changed quite a few bytes in different parts(https://www.diffchecker.com/YK5V7XvS), so any advice would be helpful for me how to do it better

@danmoseley danmoseley Mar 29, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I almost wonder then whether it would make sense to extract that "proto zip" data into a mock with a method like SetStartDiskNumber. That would make it cleaner to use and easier to maintain and extend.
It could in future eg abstract the ability to add more entries, which is more than just flipping some bytes, and maybe in future expose ways to get the bytes corrupted in interesting ways, without the tests knowing about the structure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand your idea correctly. We take s_slightlyIncorrectZip64 as a basis and create extensions for it such as SetStartDiskNumber? (and smth like SetCustomHeaderField in future)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes -- I mean, I created that for a particular test and I see it's getting used in another place, now you needed it here and had to make larger edits as you say. But those tests shouldn't need to know the zip format.

So I wonder whether that suggests it would be helpful to wrap the array in a class that exposes it and that class can take care of any modifications a test needs. For now if nothing else you could just paste your new array in there, alongside the other one, but it would be a start.

If you don't want to do that here, I think what you have is fine. (I'll let area owners sign off though)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I don't have an idea for a good implementation of this right now. It is complicated by the fact that different tests use different initialization methods (zip files in ZipTestData, byte arrays through MemberData or static byte arrays)

In my vision, it would look something like this:

var zipFile = FluentZipFileGenerator.CreateBuilder()
		.GetDefaultZipTemplate()
		.SetZip64ExtraFieldSize(args)
		.SetStartDiskNumber(args)
		.GenerateZipFile();

In this PR I can move the archive to ZipTestData/StrangeZipFiles folder.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dotnet/area-system-io-compression would have to say what they would like. I don't have any strong opinion

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should tag someone else?

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/orgs/dotnet/teams/area-system-io-compression would have to say what they would like. I don't have any strong opinion

As an ex-owner who is trying to review all stale PRs I think the PR is acceptable in the current state.

I like the concept of a builder than @mruslan97 proposed, but it can be a separate PR (let's don't block the fix anymore).

@mruslan97 as soon as you accept the CLA (#83923 (comment)) I am going to merge the PR.

@mruslan97 last, but not least big thanks for your contribution!

@adamsitnik adamsitnik added this to the 8.0.0 milestone May 18, 2023
@adamsitnik adamsitnik added the needs-author-action An issue or pull request that requires more info or actions from the author. label May 18, 2023

@danmoseley danmoseley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, apologies for losing track of this one

danmoseley

This comment was marked as duplicate.

@mruslan97

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

@ghost ghost removed the needs-author-action An issue or pull request that requires more info or actions from the author. label May 31, 2023
@danmoseley danmoseley closed this May 31, 2023
@danmoseley danmoseley reopened this May 31, 2023
@danmoseley

Copy link
Copy Markdown
Contributor

rerunning tests

@adamsitnik

Copy link
Copy Markdown
Member

The failures are unrelated (#dotnet/arcade#11683, #76454), merging! :shipit:

@adamsitnik
adamsitnik merged commit 7bcd509 into dotnet:main Jun 1, 2023
@danmoseley

Copy link
Copy Markdown
Contributor

Thanks @mruslan97 for the contribution. We'd welcome another contribution in an area that interests you! Usually PRs go in faster than this one.

@mruslan97

Copy link
Copy Markdown
Contributor Author

Thank you guys! When I get some free time I'll try to do something even more useful in future

@ghost ghost locked as resolved and limited conversation to collaborators Jul 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.IO.Compression community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zip64ExtraField should read StartDiskNumber as uint32

4 participants