Skip to content

Commit

Permalink
Merge pull request #14 from anatawa12/fix-err-with-some-archive
Browse files Browse the repository at this point in the history
Fix err with some archive
  • Loading branch information
anatawa12 authored Oct 15, 2023
2 parents 64349cd + f7fca51 commit a321ec9
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog].
### Removed

### Fixed
- Overflow substract with some archive `#14`

### Security

Expand Down
2 changes: 1 addition & 1 deletion src/output_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl OutputWindow {
}
} else {
// only one copy is needed if there is no wrap around.
copied = input.copy_to(&mut self.window[self.end..][..tail_len]);
copied = input.copy_to(&mut self.window[self.end..][..length]);
}

self.end = (self.end + copied) & WINDOW_MASK;
Expand Down
5 changes: 5 additions & 0 deletions test-assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ Some assets in directory is copied from [dotnet-assets].

- deflate64.zip is originally at https://github.com/dotnet/runtime-assets/blob/95277f38e68b66f1b48600d90d456c32c9ae0fa2/src/System.IO.Compression.TestData/ZipTestData/compat/deflate64.zip
- folder is originally at https://github.com/dotnet/runtime-assets/tree/95277f38e68b66f1b48600d90d456c32c9ae0fa2/src/System.IO.Compression.TestData/ZipTestData/refzipfolders/normal
- `issue-13/unitwf-1.5.0.minimized.zip` is originally at https://github.com/whiteflare/Unlit_WF_ShaderSuite/releases/download/UnlitWF_Shader_20231011/jp.whiteflare.unlitwf-1.5.0.zip
and removed many unnecessary zip records for testing.
- `test-assets/issue-13/logo.png` is originally at https://github.com/whiteflare/Unlit_WF_ShaderSuite/blob/505c10c19b2f632aac2596109ce6ed6f5ad79996/Logo/UnlitWF%E3%83%AD%E3%82%B4_1024.png
Please refer https://github.com/whiteflare/Unlit_WF_ShaderSuite/blob/505c10c19b2f632aac2596109ce6ed6f5ad79996/LICENSE
for license information of UnlitWF

[dotnet-assets]: https://github.com/dotnet/runtime-assets
Binary file added test-assets/issue-13/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test-assets/issue-13/unitwf-1.5.0.minimized.zip
Binary file not shown.
24 changes: 24 additions & 0 deletions tests/issue-13.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use deflate64::InflaterManaged;

static ZIP_FILE_DATA: &[u8] = include_bytes!("../test-assets/issue-13/unitwf-1.5.0.minimized.zip");
static BINARY_DATA: &[u8] = include_bytes!("../test-assets/issue-13/logo.png");

fn deflate64_data() -> &'static [u8] {
&ZIP_FILE_DATA[1182..][..34919]
}

#[test]
fn issue_13() {
let compressed_data = deflate64_data();

let mut uncompressed_data = vec![0u8; BINARY_DATA.len()];

let mut inflater = Box::new(InflaterManaged::new());
let output = inflater.inflate(compressed_data, &mut uncompressed_data);

assert_eq!(output.bytes_consumed, compressed_data.len());
assert_eq!(output.bytes_written, uncompressed_data.len());
assert!(!output.data_error, "unexpected error");

assert_eq!(uncompressed_data.as_slice(), BINARY_DATA);
}

0 comments on commit a321ec9

Please sign in to comment.