]> Cypherpunks repositories - gostls13.git/commit
image/png: fix palette extension to handle 255 color images
authorStephan Zuercher <zuercher@gmail.com>
Mon, 6 May 2019 17:55:45 +0000 (10:55 -0700)
committerNigel Tao <nigeltao@golang.org>
Wed, 8 May 2019 01:49:03 +0000 (01:49 +0000)
commit3403ee524bef9f6d2d69e11410fbf16854447d21
tree37c5f5e0eeebcde4275139396912da6916fda099
parent503e6ccd740c48f21c1d159d904b51da2d9a8ca9
image/png: fix palette extension to handle 255 color images

The PNG decode path attempts to handle paletted images that refer to
non-existent palette indicies. This PR fixes a corner case were images
that have exactly 255 palette colors and an IDAT chunk that references
palette index 255 produce an invalid image such that invoking At on
the pixel(s) in question causes an index out of range panic.

Fixes #31830

Change-Id: I34c44d9de5b9d76fe8c45c04e866fbc7f51f2a9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/175397
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/image/png/reader.go
src/image/png/reader_test.go
src/image/png/testdata/invalid-palette.png [new file with mode: 0644]