Skip to content
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

Freeze when reading broken file #215

Closed
qarmin opened this issue Jul 15, 2024 · 1 comment
Closed

Freeze when reading broken file #215

qarmin opened this issue Jul 15, 2024 · 1 comment
Labels
bug Something isn't working caused by dependency fix merged Fix is merged, but the issue will stay open until it's released.

Comments

@qarmin
Copy link

qarmin commented Jul 15, 2024

When testing zip file - raw.zip
with code (I copied this from fuzz directory)

fn check_file(file_path: &str) {
    match File::open(&file_path) {
        Ok(file) => {
            let mut zip = match zip::ZipArchive::new(file) {
                Ok(t) => t,
                Err(e) => {
                    println!("{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) => {
                        println!("{e}");
                    }
                }
            }
        }
        Err(_inspected) => (),
    }
}

it freezes here

0x00005555556b8214 in deflate64::inflater_managed::InflaterManaged::inflate (
    self=<optimized out>, input=..., output=...) at src/inflater_managed.rs:140
140	    pub fn inflate(&mut self, input: &[u8], mut output: &mut [u8]) -> InflateResult {
(gdb) backtrace
#0  0x00005555556b8214 in deflate64::inflater_managed::InflaterManaged::inflate
    (self=<optimized out>, input=..., output=...)
    at src/inflater_managed.rs:140
#1  0x000055555565f63c in deflate64::stream::{impl#3}::read<std::io::buffered::bufreader::BufReader<zip::read::CryptoReader>> (self=0x7ffff62092d8, buf=...)
    at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deflate64-0.1.8/src/stream.rs:52
#2  0x000055555565a3f8 in zip::crc32::{impl#1}::read<deflate64::stream::Deflate64Decoder<std::io::buffered::bufreader::BufReader<zip::read::CryptoReader>>> (
    self=0x7ffff62092d8, buf=...) at src/crc32.rs:43
#3  0x000055555564eabc in zip::read::{impl#2}::read (self=<optimized out>, 
    buf=...) at src/read.rs:176
#4  0x00005555556525d5 in zip::read::{impl#7}::read (self=0x7ffff6209110, 
    buf=...) at src/read.rs:1484
#5  0x0000555555645e0f in ziprs::check_file (file_path=...) at src/main.rs:40
#6  0x0000555555645141 in ziprs::main () at src/main.rs:22

@qarmin qarmin added the bug Something isn't working label Jul 15, 2024
@Pr0methean
Copy link
Member

Looks like a bug in deflate64; reporting it there...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working caused by dependency fix merged Fix is merged, but the issue will stay open until it's released.
Projects
None yet
Development

No branches or pull requests

2 participants