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).

Crates in the crates.io registry are tarball snapshots uploaded by crates' publishers. The registry is not using crates' git repositories. There is absolutely no guarantee that the repository URL declared by the crate belongs to the crate, or that the code in the repository is the code inside the published tarball.

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.