mirror of
https://github.com/golang/go
synced 2024-11-27 05:11:22 -07:00
image/png: fix crash when an alleged PNG has too much pixel data,
so that the zlib.Reader returns nil error. Fixes #7762. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/86750044
This commit is contained in:
parent
dacc020c00
commit
c47f08657a
@ -505,8 +505,14 @@ func (d *decoder) decode() (image.Image, error) {
|
||||
}
|
||||
|
||||
// Check for EOF, to verify the zlib checksum.
|
||||
n, err := r.Read(pr[:1])
|
||||
if err != io.EOF {
|
||||
n := 0
|
||||
for i := 0; n == 0 && err == nil; i++ {
|
||||
if i == 100 {
|
||||
return nil, io.ErrNoProgress
|
||||
}
|
||||
n, err = r.Read(pr[:1])
|
||||
}
|
||||
if err != nil && err != io.EOF {
|
||||
return nil, FormatError(err.Error())
|
||||
}
|
||||
if n != 0 || d.idatLength != 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user