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

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

Closed
dvyukov opened this issue Apr 9, 2015 · 3 comments
Closed

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

dvyukov opened this issue Apr 9, 2015 · 3 comments

Comments

@dvyukov
Copy link
Member

dvyukov commented Apr 9, 2015

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

@dvyukov dvyukov added this to the Go1.5 milestone Apr 9, 2015
@osocurioso
Copy link
Contributor

Sent http://golang.org/cl/9182.

The offending data has zero ImageWidth, which causes the panic.

The data also has an IFD where tags are not sorted in ascending order. According to section 2 of the TIFF spec this should not be supported. Should I file an issue?

@nigeltao
Copy link
Contributor

Yes, please file an issue.

@nigeltao
Copy link
Contributor

CC'ing @bsiegert

@rsc rsc modified the milestones: Unreleased, Go1.5 Apr 26, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
mrhyperbit23z0d added a commit to mrhyperbit23z0d/bhegde8 that referenced this issue Jun 6, 2022
Return a zero width or zero height image of the appropriate type.

Fixes golang/go#10393.

Change-Id: I3aa7b6125447726600fb072ce1e8682373ce2a57
Reviewed-on: https://go-review.googlesource.com/9182
Reviewed-by: Nigel Tao <[email protected]>
GalaxyForcew added a commit to GalaxyForcew/A1bisshy that referenced this issue Jun 6, 2022
Return a zero width or zero height image of the appropriate type.

Fixes golang/go#10393.

Change-Id: I3aa7b6125447726600fb072ce1e8682373ce2a57
Reviewed-on: https://go-review.googlesource.com/9182
Reviewed-by: Nigel Tao <[email protected]>
yi-ge3 added a commit to yi-ge3/wislie that referenced this issue Jun 6, 2022
Return a zero width or zero height image of the appropriate type.

Fixes golang/go#10393.

Change-Id: I3aa7b6125447726600fb072ce1e8682373ce2a57
Reviewed-on: https://go-review.googlesource.com/9182
Reviewed-by: Nigel Tao <[email protected]>
balloontmz6 added a commit to balloontmz6/Likewise42l that referenced this issue Jun 6, 2022
Return a zero width or zero height image of the appropriate type.

Fixes golang/go#10393.

Change-Id: I3aa7b6125447726600fb072ce1e8682373ce2a57
Reviewed-on: https://go-review.googlesource.com/9182
Reviewed-by: Nigel Tao <[email protected]>
snapbakkhfbav added a commit to snapbakkhfbav/SayedBaladohr that referenced this issue Oct 6, 2022
Return a zero width or zero height image of the appropriate type.

Fixes golang/go#10393.

Change-Id: I3aa7b6125447726600fb072ce1e8682373ce2a57
Reviewed-on: https://go-review.googlesource.com/9182
Reviewed-by: Nigel Tao <[email protected]>
MiderWong5ddop added a commit to MiderWong5ddop/sidie88f that referenced this issue Oct 7, 2022
Return a zero width or zero height image of the appropriate type.

Fixes golang/go#10393.

Change-Id: I3aa7b6125447726600fb072ce1e8682373ce2a57
Reviewed-on: https://go-review.googlesource.com/9182
Reviewed-by: Nigel Tao <[email protected]>
rorypeckwnt4v added a commit to rorypeckwnt4v/LearnByBhanuPrataph that referenced this issue Oct 7, 2022
Return a zero width or zero height image of the appropriate type.

Fixes golang/go#10393.

Change-Id: I3aa7b6125447726600fb072ce1e8682373ce2a57
Reviewed-on: https://go-review.googlesource.com/9182
Reviewed-by: Nigel Tao <[email protected]>
egorovcharenko9 added a commit to egorovcharenko9/RiceBIOC470z that referenced this issue Oct 7, 2022
Return a zero width or zero height image of the appropriate type.

Fixes golang/go#10393.

Change-Id: I3aa7b6125447726600fb072ce1e8682373ce2a57
Reviewed-on: https://go-review.googlesource.com/9182
Reviewed-by: Nigel Tao <[email protected]>
RafayGhafoorf added a commit to RafayGhafoorf/dustinsand8 that referenced this issue Oct 7, 2022
Return a zero width or zero height image of the appropriate type.

Fixes golang/go#10393.

Change-Id: I3aa7b6125447726600fb072ce1e8682373ce2a57
Reviewed-on: https://go-review.googlesource.com/9182
Reviewed-by: Nigel Tao <[email protected]>
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