Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image/png: slice bounds out of range #10414

Closed
dvyukov opened this issue Apr 10, 2015 · 1 comment
Closed

image/png: slice bounds out of range #10414

dvyukov opened this issue Apr 10, 2015 · 1 comment
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Apr 10, 2015

Run the following program on the following input:

package main

import (
    "bytes"
    "image/png"
    "io/ioutil"
    "os"
)

func main() {
    data, _ := ioutil.ReadFile(os.Args[1])
    png.Decode(bytes.NewReader(data))
}

https://drive.google.com/file/d/0B20Uwp8Hs1oCSDVROEdDVXJTdHM/view?usp=sharing

It crashes as:

panic: runtime error: slice bounds out of range

goroutine 1 [running]:
image/png.(*decoder).readImagePass(0xc208058e00, 0x7f0a79a0a4b0, 0xc208012230, 0x0, 0xc208012200, 0x0, 0x0, 0x0, 0x0)
    /ssd/src/go10/src/image/png/reader.go:521 +0x162a
image/png.(*decoder).decode(0xc208058e00, 0x0, 0x0, 0x0, 0x0)
    /ssd/src/go10/src/image/png/reader.go:323 +0x1a5
image/png.(*decoder).parseIDAT(0xc208058e00, 0x22, 0x0, 0x0)
    /ssd/src/go10/src/image/png/reader.go:648 +0x3d
image/png.(*decoder).parseChunk(0xc208058e00, 0x0, 0x0)
    /ssd/src/go10/src/image/png/reader.go:696 +0x42c
image/png.Decode(0x7f0a79a0a2d8, 0xc208014450, 0x0, 0x0, 0x0, 0x0)
    /ssd/src/go10/src/image/png/reader.go:752 +0x247
main.main()
    /tmp/png.go:12 +0x10b

I am on commit 7c37249

@dvyukov dvyukov added this to the Go1.5 milestone Apr 10, 2015
@rsc rsc removed the repo-main label Apr 14, 2015
@nigeltao
Copy link
Contributor

This was fixed by https://go-review.googlesource.com/#/c/8905/ "reject multiple tRNS chunks" aka commit 7e7d55f, which also fixed 'is the image paletted' to recognize 1-, 2- and 4-bit palettes, not just 8-bit palettes.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants