This review is from Crev, a distributed system for code reviews. To add your review, set up cargo-crev.

0.1.1 (current) Rating: Positive Thoroughness: Low Understanding: Medium

by kpreid on 2023-09-02

On a quick skim, "this sure looks like a PNG decoder": all the code is a reasonable kind of code for what it says it does, but I have not reviewed it for correctness.

I have also confirmed its functionality as a replacement for image's PNG support in my use case with a few small static PNGs.

Good things:

  • There is no unsafe code.
  • It seems to be taking care to return decoding errors rather than panicking, and the fuzz testing set up in the repository should be detecting such cases.

Potentially problematic:

  • It allocates an amount of memory determined by the input image (using Vec::with_capacity()) without checks, so a malicious image could DoS via excessive memory use (zip bomb attack).

Lib.rs has been able to verify that all files in the crate's tarball, except Cargo.lock, are in the crate's repository. Please note that this check is still in beta, and absence of this confirmation does not mean that the files don't match.

Crates in the crates.io registry are tarball snapshots uploaded by crates' publishers. The registry is not using crates' git repositories, so there is a possibility that published crates have a misleading repository URL, or contain different code from the code in the repository.

To review the actual code of the crate, it's best to use cargo crev open png-decoder. Alternatively, you can download the tarball of png-decoder v0.1.1 or view the source online.