-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Labels
Amazon Q development agentGenerate new features or iterate code based on issue descriptions and comments.Generate new features or iterate code based on issue descriptions and comments.bugSomething isn't workingSomething isn't working
Description
Describe the bug
Code
fn check_file(file_path: &str) {
let Ok(content) = fs::read(file_path) else {
return;
};
let cursor = std::io::Cursor::new(content);
let mut zip = match zip::ZipArchive::new(cursor) {
Ok(t) => t,
Err(e) => {
eprintln!("{e}");
return;
}
};
for i in 0..zip.len() {
match zip.by_index(i) {
Ok(mut file) => {
let mut buf = Vec::new();
let _ = file.read(&mut buf);
}
Err(e) => {
eprintln!("{e}");
}
}
}
}
when checking file:
will panic with info:
thread 'main' (80946) panicked at /home/runner/.cargo/git/checkouts/zip2-30411767e68ca417/54c634b/src/extra_fields/extended_timestamp.rs:26:9:
attempt to subtract with overflow
stack backtrace:
0: __rustc::rust_begin_unwind
at /rustc/07d246fc6dc227903da2955b38a59e060539a485/library/std/src/panicking.rs:698:5
1: core::panicking::panic_fmt
at /rustc/07d246fc6dc227903da2955b38a59e060539a485/library/core/src/panicking.rs:75:14
2: core::panicking::panic_const::panic_const_sub_overflow
at /rustc/07d246fc6dc227903da2955b38a59e060539a485/library/core/src/panicking.rs:175:17
3: zip::extra_fields::extended_timestamp::ExtendedTimestamp::try_from_reader
at /home/runner/.cargo/git/checkouts/zip2-30411767e68ca417/54c634b/src/extra_fields/extended_timestamp.rs:26:9
4: zip::read::parse_single_extra_field
at /home/runner/.cargo/git/checkouts/zip2-30411767e68ca417/54c634b/src/read.rs:1468:17
5: zip::read::parse_extra_field
at /home/runner/.cargo/git/checkouts/zip2-30411767e68ca417/54c634b/src/read.rs:1377:22
6: zip::read::central_header_to_zip_file_inner
at /home/runner/.cargo/git/checkouts/zip2-30411767e68ca417/54c634b/src/read.rs:1342:11
7: zip::read::central_header_to_zip_file
at /home/runner/.cargo/git/checkouts/zip2-30411767e68ca417/54c634b/src/read.rs:1249:16
8: zip::read::<impl zip::read::zip_archive::ZipArchive<R>>::read_central_header
at /home/runner/.cargo/git/checkouts/zip2-30411767e68ca417/54c634b/src/read.rs:692:24
9: zip::read::<impl zip::read::zip_archive::ZipArchive<R>>::get_metadata::{{closure}}
at /home/runner/.cargo/git/checkouts/zip2-30411767e68ca417/54c634b/src/read.rs:654:34
10: core::result::Result<T,E>::and_then
at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1483:22
11: zip::read::<impl zip::read::zip_archive::ZipArchive<R>>::get_metadata
at /home/runner/.cargo/git/checkouts/zip2-30411767e68ca417/54c634b/src/read.rs:654:18
12: zip::read::<impl zip::read::zip_archive::ZipArchive<R>>::with_config
at /home/runner/.cargo/git/checkouts/zip2-30411767e68ca417/54c634b/src/read.rs:752:22
13: zip::read::<impl zip::read::zip_archive::ZipArchive<R>>::new
at /home/runner/.cargo/git/checkouts/zip2-30411767e68ca417/54c634b/src/read.rs:745:9
14: zip_rs::check_file
at ./src/crates/zip_rs/src/main.rs:31:25
15: zip_rs::main
at ./src/crates/zip_rs/src/main.rs:23:9
16: core::ops::function::FnOnce::call_once
at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:253:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Desktop (please complete the following information):
- OS: [e.g. iOS] Ubuntu 25.04(but not really needed)
Metadata
Metadata
Assignees
Labels
Amazon Q development agentGenerate new features or iterate code based on issue descriptions and comments.Generate new features or iterate code based on issue descriptions and comments.bugSomething isn't workingSomething isn't working