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

Infinite loop when decoding some files on miniz_oxide branch #217

Closed
Shnatsel opened this issue Jun 4, 2020 · 3 comments · Fixed by #218
Closed

Infinite loop when decoding some files on miniz_oxide branch #217

Shnatsel opened this issue Jun 4, 2020 · 3 comments · Fixed by #218

Comments

@Shnatsel
Copy link
Contributor

Shnatsel commented Jun 4, 2020

Decoding some deliberately crafted files on miniz_oxide branch causes an infinite loop. The issue has been found via cargo-fuzz.

Files triggering the issue: miniz-oxide-hangs.tar.gz They do not contain valid checksums, make sure you disable checksum verification by passing --cfg=fuzzing to rustc.

This seems to be the only issue blocking the merge of miniz_oxide branch into master, which would bring up to 3x performance improvement.

@Shnatsel
Copy link
Contributor Author

Shnatsel commented Jun 4, 2020

Flame graph:
2020-04-12_17 08 56

I've added dbg! around the update call to see what it returns, here it is:

[image-png/src/decoder/mod.rs:146] self.decoder.update(buf, image_data) = Ok(
    (
        0,
        PartialChunk(
            [
                73,
                68,
                65,
                84,
            ],
        ),
    ),
)
[image-png/src/decoder/mod.rs:146] self.decoder.update(buf, image_data) = Ok(
    (
        0,
        ImageData,
    ),
)

This just repeats over and over.

@Mrmaxmeier
Copy link

Mrmaxmeier commented Dec 21, 2023

This does not seem to be fully fixed (or regressed at some point?). Here's an input file that shows the same behaviour:

$ echo "iVBORw0KGgr/6wDLSURBVEiJS1cBAAAK9bEsRUxM" | base64 -d > input.bin
$ cargo fuzz run decode input.bin -- -timeout=1
[...]
[image-png/src/decoder/mod.rs:307] self.decoder.update(buf, image_data) = Ok(
    (
        0,
        ImageData,
    ),
)
[...]
SUMMARY: libFuzzer: timeout

@fintelia
Copy link
Contributor

Just tested all the images referenced in this thread and they're all now handled properly.

The files from miniz-oxide-hangs.tar.gz all have height=0, which was addressed in #445 (and perhaps earlier). The input.bin example has a IDAT chunk before any IHDR, which #456 now specifically rejects.

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 a pull request may close this issue.

3 participants