Skip to content

x/image/tiff: integer divide by zero #10393

Closed
@dvyukov

Description

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/0B20Uwp8Hs1oCNkpVc2VEdDE0RmM/view?usp=sharing

It crashes with:

panic: runtime error: integer divide by zero
[signal 0x8 code=0x1 addr=0x45cd86 pc=0x45cd86]

goroutine 1 [running]:
runtime.gopanic(0x52ae80, 0xc20800e230)
    src/runtime/panic.go:477 +0x3fe fp=0xc208041668 sp=0xc2080415e8
runtime.panicdivide()
    src/runtime/panic.go:24 +0x52 fp=0xc208041690 sp=0xc208041668
runtime.sigpanic()
    src/runtime/sigpanic_unix.go:31 +0x1dd fp=0xc2080416e0 sp=0xc208041690
golang.org/x/image/tiff.Decode(0x7f4174bb52d8, 0xc208014480, 0x7f4174bb5380, 0xc2080104c0, 0x0, 0x0)
    src/golang.org/x/image/tiff/reader.go:547 +0x6c6 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

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions