Skip to content

test: generate corrupt gzip fixture at runtime#550

Merged
Byron merged 1 commit into
rust-lang:mainfrom
nanookclaw:fix/generate-corrupt-gzip-fixture
Jun 20, 2026
Merged

test: generate corrupt gzip fixture at runtime#550
Byron merged 1 commit into
rust-lang:mainfrom
nanookclaw:fix/generate-corrupt-gzip-fixture

Conversation

@nanookclaw

Copy link
Copy Markdown
Contributor

Summary

Closes #549.

This removes tests/corrupt-gz-file.bin and updates test_extract_failure to generate the corrupt gzip input in memory. The test now writes a small valid gzip stream with GzEncoder, flips a byte in the CRC32 portion of the gzip footer, then verifies GzDecoder still reports io::ErrorKind::InvalidInput.

That keeps the same failure-path coverage without shipping an opaque gzip-looking binary fixture that can trip security scanners.

Verification

  • cargo fmt --check
  • cargo test --test gunzip
  • cargo test --test gunzip --features zlib-rs --no-default-features
  • cargo test --test gunzip --features zlib --no-default-features

@EhhChris

Copy link
Copy Markdown

Beat me to it on a travel day, thank you!

@Byron Byron 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.

Wonderful, thanks so much!

Comment thread tests/gunzip.rs
fn test_extract_failure() {
let result = extract_file(Path::new("tests/corrupt-gz-file.bin"));
let mut encoder = GzEncoder::new(Vec::new(), Compression::default());
encoder.write_all(b"corrupt me").unwrap();

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.

😁

@Byron
Byron merged commit 1670537 into rust-lang:main Jun 20, 2026
15 checks passed
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.

Test for corrupt gz file trips up corporate security

3 participants