-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
CRC Calculations Are Ocassionally Incorrect #229
Comments
Thanks for making me aware of this. Do you have a file at hand that showcases this behavior? |
I can repro this consistently when using ZIPFoundation to archive build products: % unzip Mockingbird.zip
Archive: Mockingbird.zip
inflating: Mockingbird/LICENSE.md
creating: Mockingbird/Libraries/
inflating: Mockingbird/Libraries/lib_InternalSwiftSyntaxParser.dylib
inflating: Mockingbird/Libraries/LICENSE.txt
inflating: Mockingbird/mockingbird bad CRC 0e8ab0ad (should be c9189cde) Attached the file here: Mockingbird.zip And here’s how we’re calling ZIPFoundation in our build pipeline: https://github.com/birdrides/mockingbird/blob/master/Sources/MockingbirdAutomationCli/Commands/Build.swift#L52-L55 You can repro it locally by checking out Mockingbird and running |
The new automation pipeline uses ZIP Foundation to create archives of the build products. Unfortunately, ZIP Foundation produces malformed CRCs for the mockingbird binary executable (see weichsel/ZIPFoundation#229). This change replaces ZIP Foundation with the Unix zip command and fixes how the Mockingbird.zip archive is inflated by the CLI launcher.
Opened a PR here: #243 @andrewchang-bird Does this fix your issue? |
Yep, looks like |
@andrewchang-bird Thanks for confirming. Merged - will be part of next release. |
The new automation pipeline uses ZIP Foundation to create archives of the build products. Unfortunately, ZIP Foundation produces malformed CRCs for the mockingbird binary executable (see weichsel/ZIPFoundation#229). This change replaces ZIP Foundation with the Unix zip command and fixes how the Mockingbird.zip archive is inflated by the CLI launcher.
@weichsel thanks for this nice project and helping to get this issue fixed. Do you have an estimation when the next version with the fix will go live? |
Hi @marcussc |
The CRC calculation in the Data.process(...) is incorrect. In the case where the loop continues without stream.src_size getting set to zero, another pass with the same datablock is done on the CRC, causing it to be incorrect. compression_stream_process does not necessarily consume all the bytes.
unzip utilities on macOS are forgiving on incorrect CRCs (and ZIPFoundation itself lets you ignore them), but many other libraries will error out if the stored CRCs in the ZIP file don't match the CRC of the decoded file/bytes.
The correct action for COMPRESSION_STREAM_ENCODE is to run the CRC pass only when a new block of data is read from the provider.
The text was updated successfully, but these errors were encountered: