-
Notifications
You must be signed in to change notification settings - Fork 40
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
data_start is incorrect when reading an aligned file #33
Comments
This exact test case was broken again with 2.1.4. Please reopen.
I would bisect it, but your history is utterly broken.
Would it be possible to have some kind of quality assurance by any chance? |
I added the method Line 784 in c3d9123
test_alignment() is different from your code, besides operating on memory rather than on a filesystem.
|
The following test reproduces it: #[test]
fn test_alignment() {
let page_size = 4096;
let mut data = Vec::new();
{
let options = SimpleFileOptions::default()
.compression_method(CompressionMethod::Stored)
.with_alignment(page_size);
let mut zip = ZipWriter::new(io::Cursor::new(&mut data));
let contents = b"sleeping";
let () = zip.start_file("sleep", options).unwrap();
let _count = zip.write(&contents[..]).unwrap();
}
{
let mut zip = ZipArchive::new(io::Cursor::new(&mut data)).unwrap();
let file = zip.by_index(0).unwrap();
assert_eq!(file.name(), "sleep");
assert_eq!(file.data_start(), page_size.into());
}
} The difference to the existing one is that it doesn't use |
Ah, this is actually a different bug: the data starts at byte 4096 as expected (I confirmed this by adding |
Makes sense. But irrespective of that the zip archive created with Here are two archives created using
$ unzip test-2.1.5.zip
Archive: test-2.1.5.zip
extracting: test-stable-addrs-stripped-elf-with-dwarf.bin bad CRC 2886939d (should be d9becfd9)
extracting: zip-dir/test-no-debug.bin bad CRC 239d2efa (should be 0e0e8dc5)
extracting: libtest-so.so bad CRC ac70132d (should be f886cd80)
extracting: libtest-so-no-separate-code.so bad CRC 82120180 (should be 33423096) |
That's yet another different issue: #195. Sorry that the overall state of The code also has some known quality issues, such as how |
Yeah, I understand. I am not blocked on this getting fixed as I've blacklisted 2.1.4 and higher and I don't really use the crate in production. That said, it is very annoying to have to deal with regressions like this on a 1.x or 2.x crate. Almost equally bad is not having a buildable commit history. Root causing issues like this should be trivial and instead we are running in circles for nothing.
It's possible, but I kind of doubt it. The issue may manifest as checksum mismatches in my paste, but I am not convinced that is necessarily the actual issue. For one, #195 mentions version 2.1.3. This version is definitely behaving properly for my use case. Based on my limited testing, data offsets in the local file headers seemed off (though again, that may not be the actual root cause either, it is hard for me to tell). If we compare the hex dumps there are a bunch of differences between the two, most notably towards the end. I am not fluent enough to judge validity of those differences at this point. |
I've mentioned my need for a co-admin on the relevant Slack channels at work; hopefully someone can either recommend one, or step up to the plate themselves and be at least as qualified as me. |
Also, I am not setting |
…pt archive with overlength extra data, and data_start locations when reading the archive back were also wrong (#221) * fix: Rare combination of settings could lead to writing a corrupt archive with overlength extra data * fix: Previous fix was breaking alignment * style: cargo fmt --all * fix: ZIP64 header was being written twice * style: cargo fmt --all * ci(fuzz): Add check that file-creation options are individually valid * fix: Need to update extra_data_start in deep_copy_file * style: cargo fmt --all * test(fuzz): fix bug in Arbitrary impl * fix: Cursor-position bugs when merging archives or opening for append * fix: unintended feature dependency * style: cargo fmt --all * fix: merge_contents was miscalculating new start positions for absorbed archive's files * fix: shallow_copy_file needs to reset CDE location since the CDE is copied * fix: ZIP64 header was being written after AES header location was already calculated * fix: ZIP64 header was being counted twice when writing extra-field length * fix: deep_copy_file was positioning cursor incorrectly * test(fuzz): Reimplement Debug so that it prints the method calls actually made * test(fuzz): Fix issues with `Option<&mut Formatter>` * chore: Partial debug * chore: Revert: `merge_contents` already adjusts header_start and data_start * chore: Revert unused `mut` * style: cargo fmt --all * refactor: eliminate a magic number for CDE block size * chore: WIP: fix bugs * refactor: Minor refactors * refactor: eliminate a magic number for CDE block size * refactor: Minor refactors * refactor: Can use cde_start_pos to locate ZIP64 end locator * chore: Fix import that can no longer be feature-gated * chore: Fix import that can no longer be feature-gated * refactor: Confusing variable name * style: cargo fmt --all and fix Clippy warnings * style: fix another Clippy warning --------- Signed-off-by: Chris Hennick <[email protected]>
…nt-padded file (#228) * test: Add test that `data_start` is correctly detected while reading * chore: Fix imports
I tried upgrading to version 1.1 and it seems as if handling of alignment is broken.
fails with:
Similar code on
0.6.4
works fine:Am I misunderstanding what is being aligned?
The text was updated successfully, but these errors were encountered: