Prior to this commit, png.Decode would allow TrueColor PNG images that
have one but not both of PLTE and tRNS chunks.
Fixes #54142
Change-Id: I259c1fff86a0aa5640dbadf7ad834e05fbd1430c
Reviewed-on: https://go-review.googlesource.com/c/go/+/424916
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Nigel Tao (INACTIVE; USE @golang.org INSTEAD) <nigeltao@google.com>
return cbP1 <= cb && cb <= cbP8
}
+func cbTrueColor(cb int) bool {
+ return cb == cbTC8 || cb == cbTC16
+}
+
// Filter type, as per the PNG spec.
const (
ftNone = 0
if d.stage != dsSeenPLTE {
return chunkOrderError
}
+ } else if cbTrueColor(d.cb) {
+ if d.stage != dsSeenIHDR && d.stage != dsSeenPLTE {
+ return chunkOrderError
+ }
} else if d.stage != dsSeenIHDR {
return chunkOrderError
}