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 #12545

Closed
bmbernie opened this issue Sep 8, 2015 · 1 comment
Closed

image/png: slice bounds out of range #12545

bmbernie opened this issue Sep 8, 2015 · 1 comment
Milestone

Comments

@bmbernie
Copy link

bmbernie commented Sep 8, 2015

Run the following program on the following input:

package main

import (
    "bytes"
    "image/png"
)

func main() {
    data := "\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x00" +
        "\x04\x00\x00\x00\x04\x00\x00\x00\x00\x86\xfc\x9f\xc30000IDA" +
        "T8\x11cn\x000"

    img, err := png.Decode(bytes.NewReader([]byte(data)))
    if err != nil {
        return
    }
    var w bytes.Buffer
    err = png.Encode(&w, img)
    if err != nil {
        panic(err)
    }
}

It crashes as:

panic: runtime error: index out of range

goroutine 1 [running]:
image/png.(*decoder).readImagePass(0x8202e8e00, 0x882045b3e8, 0x8203020a0, 0x0, 0x820302000, 0x0, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.5/libexec/src/image/png/reader.go:472 +0x2780
image/png.(*decoder).decode(0x8202e8e00, 0x0, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.5/libexec/src/image/png/reader.go:328 +0x1a1
image/png.(*decoder).parseIDAT(0x8202e8e00, 0x30303030, 0x0, 0x0)
    /usr/local/Cellar/go/1.5/libexec/src/image/png/reader.go:673 +0x3a
image/png.(*decoder).parseChunk(0x8202e8e00, 0x0, 0x0)
    /usr/local/Cellar/go/1.5/libexec/src/image/png/reader.go:722 +0x406
image/png.Decode(0x882045b210, 0x8202e22d0, 0x0, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.5/libexec/src/image/png/reader.go:778 +0x210
main.main()
    /Users/bmb/go/src/github.com/bmbernie/pngtest/pngtest.go:13 +0x121

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Sep 8, 2015
@gopherbot
Copy link

CL https://golang.org/cl/14411 mentions this issue.

@golang golang locked and limited conversation to collaborators Sep 8, 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