Skip to content

feat: add crc32 ignore option#710

Open
Its-Just-Nans wants to merge 5 commits intomasterfrom
option-disable-crc
Open

feat: add crc32 ignore option#710
Its-Just-Nans wants to merge 5 commits intomasterfrom
option-disable-crc

Conversation

@Its-Just-Nans
Copy link
Member

@Its-Just-Nans Its-Just-Nans commented Mar 5, 2026

fix #170

actually, we can do it pretty easily since the ignore code is already here

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new feature that allows users to ignore CRC32 checksum validation when reading zip files. This enhancement provides greater flexibility for handling archives that might have non-standard or intentionally incorrect CRC32 values, addressing a specific issue where strict validation could prevent file access.

Highlights

  • New ignore_crc option: Introduced an ignore_crc boolean field to ZipReadOptions and a corresponding ignore_crc32 builder method, allowing users to bypass CRC32 checksum validation.
  • Conditional CRC32 validation: Modified the internal make_reader function to accept an Option<u32> for the CRC32 value and implemented logic to conditionally disable CRC32 checks based on the new ignore_crc option and whether the file is AE2 encrypted.
  • New test coverage: Added a new test file (tests/crc32.rs) with specific test cases to verify both the default CRC32 validation behavior (error on mismatch) and the successful reading of files when CRC32 checks are explicitly ignored.
Changelog
  • src/read.rs
    • Updated the make_reader function signature to accept an Option<u32> for the crc32 parameter, enabling conditional CRC32 validation.
    • Implemented logic within make_reader to determine if CRC32 checks should be disabled based on the presence of a CRC32 value and AE2 encryption status.
    • Added a new ignore_crc: bool field to the ZipReadOptions struct.
    • Provided a public builder method ignore_crc32(bool) for ZipReadOptions to configure the new CRC32 ignore behavior.
    • Modified the ZipArchive::make_reader call to pass the crc32 value as an Option<u32> based on the ignore_crc option.
    • Adjusted calls to make_reader in read_zipfile_from_stream and read_zipfile_from_stream_with_compressed_size to wrap the crc32 in Some().
  • tests/crc32.rs
    • Added a new test file to specifically cover CRC32 validation scenarios.
    • Included a test invalid_crc32_should_error to confirm that invalid CRC32 values correctly lead to an error by default.
    • Added a test invalid_crc32_ignored_should_success to verify that reading succeeds when an invalid CRC32 is present but the ignore_crc32 option is enabled.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

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

This PR successfully adds the ability to ignore CRC32 validation when reading ZIP files, addressing issue #170. The implementation is clean and follows the existing patterns in the codebase. The changes include proper option handling in ZipReadOptions, correct parameter type changes to support optional CRC32 validation, and comprehensive test coverage that validates both default behavior (CRC validation enabled) and the new functionality (CRC validation disabled when requested). No blocking issues found.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a useful feature to ignore CRC32 checks when reading zip files. The implementation is sound. I've provided a suggestion to improve the conciseness and readability of the logic in src/read.rs. Additionally, I've identified and suggested a fix for a bug in the new test file where incorrect offsets were being used to corrupt CRC32 values, which could lead to unreliable test results.

@Its-Just-Nans Its-Just-Nans requested a review from Pr0methean March 5, 2026 05:09
@Its-Just-Nans Its-Just-Nans self-assigned this Mar 5, 2026
@Its-Just-Nans Its-Just-Nans mentioned this pull request Mar 11, 2026
5 tasks
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.

Add option to disable crc-checking

1 participant