golang/go

x/image/webp: index out of range

dvyukov opened this issue · 4 comments

Run the following program on the following file:

package main

import (
    "bytes"
    "golang.org/x/image/webp"
    "io/ioutil"
    "os"
)

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

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

Crashes with:

runtime.panicindex()
    runtime/panic.go:12 +0x52 fp=0xc208041980 sp=0xc208041958
golang.org/x/image/vp8l.(*decoder).decodePix(0xc20800a440, 0x640000000a, 0x100000fa0, 0x0, 0x0, 0x0, 0x0, 0x0)
    golang.org/x/image/vp8l/decode.go:440 +0xc51 fp=0xc208041b38 sp=0xc208041980
golang.org/x/image/vp8l.Decode(0x7f48959fb1e8, 0xc20802e080, 0x0, 0x0, 0x0, 0x0)
    golang.org/x/image/vp8l/decode.go:589 +0x1a5 fp=0xc208041cb8 sp=0xc208041b38
golang.org/x/image/webp.decode(0x7f48959fb1c0, 0xc2080143f0, 0x401e00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    golang.org/x/image/webp/decode.go:117 +0xc56 fp=0xc208041ea8 sp=0xc208041cb8
golang.org/x/image/webp.Decode(0x7f48959fb1c0, 0xc2080143f0, 0x0, 0x0, 0x0, 0x0)
    golang.org/x/image/webp/decode.go:256 +0x55 fp=0xc208041f08 sp=0xc208041ea8
main.main()
    webp.go:12 +0x10b fp=0xc208041f90 sp=0xc208041f08

My repository is on commit 65a798f031fd31a65574938bed2ec44c2bcba496.

CL - https://go-review.googlesource.com/#/c/9912/ don't exactly fix this, but it certainly fixes one of the bug associated with this issue. Now getting io.ErrUnexpectedEOF instead.

I'm able to decode the referenced file using libwebp which means that file is in valid webp format.

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

@nigeltao thanks for reviewing and merging CL 9912. Should I open a new issue for the problem I mentioned in last comment?

Re-opening this issue (if gopherbot automatically closes it at some point) seems fine to me.