Skip to content
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

Open branch, to fix multiple crashes on repeated zip archives reading… #200

Merged
merged 5 commits into from
Nov 25, 2016

Conversation

vladimdemidov
Copy link
Contributor

…. Added fix.

@adamhathcock
Copy link
Owner

Thanks!

I think I see what the changes are but can you make the spacing consistent?

Also, other minor things.

@@ -1,44 +1,44 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Copy link
Owner

Choose a reason for hiding this comment

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

Line endings changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you please clarify, what newline character do you use?

Copy link
Owner

Choose a reason for hiding this comment

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

Maybe it's still left over from before I tried to normalize endings but I have gitattributes set to auto.

Question is: why is this file changing at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The solution file was regenerated by Visual Studio. I don't see any real changes.

Copy link
Owner

Choose a reason for hiding this comment

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

So revert it then please. Whitespace changes make a lot of noise for reviewing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry i can't revert this file because my Git didn't see any changes.

//only read 10 less because the last ten are auth bytes
return new WinzipAesCryptoStream(plainStream, Header.WinzipAesEncryptionData, Header.CompressedSize - 10);
}
return Header.WinzipAesEncryptionData != null ? new WinzipAesCryptoStream(plainStream, Header.WinzipAesEncryptionData, Header.CompressedSize - 10) : plainStream;
Copy link
Owner

Choose a reason for hiding this comment

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

Why do this?

I hate the tertiary operator. It's not readable on a single line here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@@ -65,9 +65,28 @@ protected byte[] EncodeString(string str)

internal List<ExtraData> Extra { get; set; }

internal PkwareTraditionalEncryptionData PkwareTraditionalEncryptionData { get; set; }
//internal PkwareTraditionalEncryptionData PkwareTraditionalEncryptionData { get; set; }
Copy link
Owner

Choose a reason for hiding this comment

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

Don't leave commented out code, please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@adamhathcock
Copy link
Owner

Fix for #197 I think.

@adamhathcock
Copy link
Owner

Please revert all the whitespace changes. You've spaced in way too far on some files for no reason.

#else
&& (Header.PkwareTraditionalEncryptionData != null))
#endif
if ((Header.CompressedSize == 0) && !string.IsNullOrEmpty(Header.Password))
Copy link
Owner

Choose a reason for hiding this comment

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

This doesn't make sense. The lack of a password should be it's own if statement. Not ANDed with this check.

@@ -165,20 +162,16 @@ private void LoadHeader(ZipFileEntry entryHeader, Stream stream)
switch (mode)
{
case StreamingMode.Seekable:
{
Copy link
Owner

Choose a reason for hiding this comment

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

don't remove braces please. They're there for a reason.

#else
&& (Header.PkwareTraditionalEncryptionData != null))
#endif
if (Header.CompressedSize == 0)
Copy link
Owner

Choose a reason for hiding this comment

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

I guess this is my bad while this is busting things.

I can't think through the logic at the moment but the null checks above where used to see if encryption was being attempted.

I guess that's what you were doing with the password being specified. Sorry, I guess that needs to be put back as I misread.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that define that file is encrypted can be checked by using Header.Flags. I think it easiest way, because in previous code variant, encryptor in HederFactory is created based on this flag.

@adamhathcock adamhathcock merged commit 3f7e559 into adamhathcock:master Nov 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants