Thread with 16 posts

jump to expanded post

me: so, the purpose of the adler-32 checksum at the end of a png’s zlib stream…
you: …is to check the data integrity, right?
me: no, the purpose of a system is what it does
you: oh no
me: and what it does is let the decompressor have little a buffer overrun, as a treat
you:

Open thread at this post
Fabian Giesen , @rygorous@mastodon.gamedev.place
(open profile)

@hikari That is incorrect. There've been several vulns in stb_image but this was never one of them.

All the reads in that path go through zget8 which just keeps going and returning 0 (and not advancing the read cursor) at the end of the buffer. So no actual overrun.

The actual original issue was that in certain situations you could get stuck in an infinite loop reading ever more implicit zeros that way, never returning an error. (So DoS)

Open remote post (opens in a new window)
Fabian Giesen , @rygorous@mastodon.gamedev.place
(open profile)

@hikari The EOF check was added later to prevent this, and is too eager (triggers when we fill the extra bits into the buffer - which is speculative - not after we actually consume them), but this was fine for regular PNGs which always have the 32-bit Adler32 footer after them.

In CgBIs though which got both the new overeager check _and_ no Adler32 footer, it can misfire.

Open remote post (opens in a new window)