Skip to content

x/image/tiff: index out of range #10394

Description

@dvyukov

Run the following program on the following input:

package main

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

func main() {
    data, _ := ioutil.ReadFile(os.Args[1])
    img, err := tiff.Decode(bytes.NewReader(data))
    if err != nil {
        return
    }
    var w bytes.Buffer
    err = tiff.Encode(&w, img, nil)
    if err != nil {
        panic(err)
    }
}

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

It crashes with:

panic: runtime error: index out of range

goroutine 1 [running]:
runtime.gopanic(0x52ae80, 0xc20800e210)
    src/runtime/panic.go:477 +0x3fe fp=0xc2080414b8 sp=0xc208041438
runtime.panicindex()
    src/runtime/panic.go:12 +0x52 fp=0xc2080414e0 sp=0xc2080414b8
golang.org/x/image/tiff.(*decoder).readBits(0xc208070000, 0x1, 0x36)
    src/golang.org/x/image/tiff/reader.go:170 +0x104 fp=0xc2080414e8 sp=0xc2080414e0
golang.org/x/image/tiff.(*decoder).decode(0xc208070000, 0x7f2eb8943380, 0xc2080104c0, 0x0, 0x0, 0x99, 0x37, 0x0, 0x0)
    src/golang.org/x/image/tiff/reader.go:251 +0x86e fp=0xc2080416e0 sp=0xc2080414e8
golang.org/x/image/tiff.Decode(0x7f2eb89432d8, 0xc208014480, 0x7f2eb8943380, 0xc2080104c0, 0x0, 0x0)
    src/golang.org/x/image/tiff/reader.go:593 +0xadc fp=0xc208041ed0 sp=0xc2080416e0
main.main()
    /tmp/tiff.go:12 +0x132 fp=0xc208041f90 sp=0xc208041ed0

I am on commit 65a798f031fd31a65574938bed2ec44c2bcba496

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions