-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
Milestone
Description
The following program crashes with "image block is out of bounds". Either Decode should not produce such image, or Encode should accept it.
package main
import (
"bytes"
"image/gif"
"strings"
)
func main() {
img, err := gif.Decode(strings.NewReader(data))
if err != nil {
return
}
var w bytes.Buffer
err = gif.Encode(&w, img, nil)
if err != nil {
panic(err)
}
}
var data = "GIF89a0000000,0\x000\x00\x1e\x00" +
"\x14\x00\x8600000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000U\xa1\xb1$\x9b\x9e\x97\xb97,\xaf\x1ay\xa4\x14" +
"\xea3\x96\x97\xc6e_\x10G\x8eS\xd2Mm\xa9\xa0\x19\xefF\xfe" +
"\x97ợ.\xd0;0\x97\x14\xd50v!\xfbȒ\xe2ߗ" +
"_}\x99`\v״\x98\xa8\xe0\xbdݺ\xaa\xce6\xd2MT " +
"p\xe03\xdb\x10?J\xa8\xbe\xdc\xd1\x13\x89f\x05\xc4n;\xf3\x1c" +
"\b5\xe0\x91\xdf\xde\x12qE<\xd6P\xf1O\x88\x8aD\xdf\u007f\xbc" +
"\xc9Ͱ\x99\xb7\xe7n\u008dN9l\xca\xd0k8\x8e\xee\x84\xcb" +
"\xbd\xf6K\x03\xc2s\x80|\xfb\xe91r\xbc\xfb\xeeu\x12r\u007f\xc0" +
"}ȩ\xad\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\a$F\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b" +
"\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" +
"\xa0\xa1\xa2\x85\x81\x00;"
panic: gif: image block is out of bounds
goroutine 1 [running]:
main.main()
gif.go:17 +0x19d
go version devel +fbb4c74 Sat May 2 02:48:32 2015 +0000 darwin/amd64