go/src/image
Nigel Tao 8c4ea3140e image/png: fix interlaced palette out-of-bounds
PNG images can be paletted, where each pixel value (a uint8) indexes a
slice of colors. In terms of wire format, the PLTE chunk explicitly
contains the palette length. However, in practice, some arguably
malformed images contain pixel values greater than or equal to the
explicit PLTE length.

Go's image/png decoder accomodates such images by lengthening the
decoded image's palette if the implicit maximum is larger than the
explicit maximum. This was already done, prior to this commit, by the
"if len(paletted.Palette) <= int(idx)" lines in decoder.readImagePass.

Separately, PNG images can also be interlaced, where the final image is
the result of merging multiple partial images, also called passes. Prior
to this commit, we applied the palette lengthening to the pass images
but not the final image. This commit fixes that.

Fixes #48612

Change-Id: I77606538cc9a504fbd726071756ebcd10c9da73f
Reviewed-on: https://go-review.googlesource.com/c/go/+/354709
Trust: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2021-10-08 01:18:01 +00:00
..
color all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
draw image/draw: add RGBA64Image fast path for RGBA dst 2021-09-27 10:10:16 +00:00
gif image/gif: fix typo in the comment (io.ReadByte -> io.ByteReader) 2021-06-30 17:58:50 +00:00
internal/imageutil all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
jpeg image: resolve the TODO of doc comment style 2021-02-24 01:35:53 +00:00
png image/png: fix interlaced palette out-of-bounds 2021-10-08 01:18:01 +00:00
testdata
decode_example_test.go
decode_test.go image: add missing error check in test 2019-05-23 15:51:48 +00:00
format.go
geom.go image: add Uniform.RGBA64At and Rectangle.RGBA64At 2021-06-30 02:00:49 +00:00
geom_test.go
image.go image: add RGBA64Image interface 2021-06-18 23:57:09 +00:00
image_test.go image: add Uniform.RGBA64At and Rectangle.RGBA64At 2021-06-30 02:00:49 +00:00
names.go image: add Uniform.RGBA64At and Rectangle.RGBA64At 2021-06-30 02:00:49 +00:00
ycbcr.go image: add RGBA64Image interface 2021-06-18 23:57:09 +00:00
ycbcr_test.go