-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Avoid reading the whole file into memory when adding a file to a .zip archive #7123
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
Conversation
Refresh widgets on import Fix duplicate favorites section
Does this fix zip bombs? |
My understanding is that zip bombs are about extracting archives, this reduces memory usage when compressing files. |
But now I'm curious to test what happens extracting the famous |
Ah nevermind: those kinds of zip bombs only work if you try recursively unzip nested archives (which we don't). This one (non recursive) works though: https://www.bamsoftware.com/hacks/zipbomb/. It's a 42Kb file that gets expanded to 5Gb, but the only consequence is that you occupy some disk space (and you can stop extraction at any moment). |
@gave92 would it make sense to switch to using 7zip? |
@yaichenbaum we can look at integrating 7zip through e.g SevenZipExtractor. I suggest we still merge this as it's beneficial for FTP too. Bundling a custom SharpZipLib is also not too bad if it's temporary (till we switch to 7zip). |
@yaichenbaum I'm going to review it next weekend. If you want to, you can review it now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From initial look, it looks ok!
Resolved / Related Issues
Items resolved / related issues by this PR.
Details of Changes
Add details of changes here.
Unfortunately this requires some trivial changes to SharpZipLib which currently does not support opening a ZipOutputStream to an existing archive. Modified nuget package added to the project, like it was done for
microsoft.management.infrastructure.runtime.win
To test: copy a 1GB and paste it into a .zip archive. See Files.exe memory not-growing anymore to 1GB :)
Validation
How did you test these changes?