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

compress/lzw: panic: index out of range in reader #20597

Closed
zgrim opened this issue Jun 7, 2017 · 8 comments
Closed

compress/lzw: panic: index out of range in reader #20597

zgrim opened this issue Jun 7, 2017 · 8 comments
Milestone

Comments

@zgrim
Copy link

zgrim commented Jun 7, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version devel +90b39f33c4 Wed Jun 7 05:55:11 2017 +0000 linux/amd64

What operating system and processor architecture are you using (go env)?

linux amd64

What did you do?

https://play.golang.org/p/54wxXb3tnW

What did you expect to see?

error in gif decoder or "ok\n"

What did you see instead?

panic: runtime error: index out of range

goroutine 1 [running]:
compress/lzw.(*decoder).decode(0xc4200baa00)
/home/zgrim/go1.9/src/compress/lzw/reader.go:178 +0x505
compress/lzw.(*decoder).Read(0xc4200baa00, 0xc4200e406f, 0x1fe8, 0x1fe8, 0x1003, 0x0, 0x0)
/home/zgrim/go1.9/src/compress/lzw/reader.go:132 +0x2c
io.ReadAtLeast(0x7fa9a1bf4018, 0xc4200baa00, 0xc4200d6000, 0x10057, 0x10057, 0x10057, 0x44dac0, 0x7fa900000018, 0xc42004bbf8)
/home/zgrim/go1.9/src/io/io.go:307 +0x86
io.ReadFull(0x7fa9a1bf4018, 0xc4200baa00, 0xc4200d6000, 0x10057, 0x10057, 0x40ce68, 0x4bbda0, 0x4c0e60)
/home/zgrim/go1.9/src/io/io.go:325 +0x58
image/gif.readFull(0x7fa9a1bf4018, 0xc4200baa00, 0xc4200d6000, 0x10057, 0x10057, 0xc4200baa00, 0x0)
/home/zgrim/go1.9/src/image/gif/reader.go:67 +0x5a
image/gif.(*decoder).decode(0xc420090000, 0x5453a0, 0xc42000c080, 0x0, 0x0, 0x0)
/home/zgrim/go1.9/src/image/gif/reader.go:228 +0x313
image/gif.Decode(0x5453a0, 0xc42000c080, 0xc42000c080, 0x0, 0x0, 0xa2)
/home/zgrim/go1.9/src/image/gif/reader.go:494 +0x5d
main.main()
/tmp/lzw/t.go:21 +0x99
exit status 2

@davecheney
Copy link
Contributor

Thats, uh, an interesting image.

Smaller reproducer

package main

import (
        "fmt"
        "image/gif"
        "os"
)

func main() {

        // wget "http://cdn.wwwpromoter.com/4313aa528cc1ffcd148c2585e88f8946872a4f5ec1b35b5e5b4cf2da0ea26283bc443665c1812ae18e520ca365540e44_er.gif" -Ot.gif

        r, err := os.Open("./t.gif")
        if err != nil {
                panic(err)
        }
        _, err = gif.Decode(r)
        if err != nil {
                panic(err)
        }
        fmt.Println("ok")
}

@davecheney
Copy link
Contributor

Possibly caused by 642a1cc

Marking as Go 1.9 as this is a possible regression form 1.8

/cc @dsymonds

@davecheney davecheney added this to the Go1.9 milestone Jun 7, 2017
@dsymonds
Copy link
Contributor

dsymonds commented Jun 7, 2017

@nigeltao would be the culprit if it's 642a1cc.

@davecheney
Copy link
Contributor

davecheney commented Jun 7, 2017 via email

@dsymonds
Copy link
Contributor

dsymonds commented Jun 7, 2017

Well, I carry some of the blame, since I reviewed his code. You would have thought I'd have learned by now... ;-)

@ALTree ALTree changed the title compress/lzw/reader panic index out of range compress/lzw: panic: index out of range in reader Jun 7, 2017
@zgrim
Copy link
Author

zgrim commented Jun 7, 2017

Thats, uh, an interesting image.

Sorry, just boring data from the logs, but i should've picked a more decent one. :) So, here's another, from here, if preferable.

@dgryski
Copy link
Contributor

dgryski commented Jun 7, 2017

The new image code should definitely be fuzzed.

@gopherbot
Copy link
Contributor

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

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

5 participants