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

image/gif: decode fails with "gif: too much image data" #35503

Open
wodim opened this issue Nov 11, 2019 · 2 comments
Open

image/gif: decode fails with "gif: too much image data" #35503

wodim opened this issue Nov 11, 2019 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@wodim
Copy link

wodim commented Nov 11, 2019

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

$ go version
go version go1.13.4 windows/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\User\AppData\Local\go-build
set GOENV=C:\Users\User\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=E:\vagrant\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\User\AppData\Local\Temp\go-build365934466=/tmp/go-build -gno-record-gcc-switches

What did you do?

I have attached a zip file with three gif images that image/gif can't open (I get the message "gif: too much image data") but that other viewers can open fine. I assume they are actually invalid but perhaps image/gif could be changed to be more forgiving?

unknown.zip

@smasher164 smasher164 added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 11, 2019
@smasher164 smasher164 changed the title image/gif: images that fail to decode with "gif: too much image data" image/gif: decode fails with "gif: too much image data" Nov 11, 2019
@smasher164
Copy link
Member

/cc @nigeltao

as referenced this issue in as/goissues Nov 12, 2019
The author provides three example images which fail to decode
with the standard library's 'image/gif' package. The underlying
cause appears to be reading the "End of Information Code" from
the LZW decoder.

The decoder returns 1 byte read instead of zero, as well as a nil
error instead of io.EOF or io.ErrUnexpectedEOF. This triggers
the errTooMuch condition.

The solution to this is to comment out the errTooMuch return,
this results in a successful decode, but also fails some of the
tests. More investigation is necessary to determine whether
this solution is sound in practice.
@as
Copy link
Contributor

as commented Nov 12, 2019

The underlying cause appears to be reading the "End of Information Code" from the LZW decoder.

The decoder returns 1 byte read instead of 0, as well as a nil error instead of io.EOF or io.ErrUnexpectedEOF. This triggers the errTooMuch condition.

One solution to this is to comment out the errTooMuch return in the if statement, this results in a successful decode, but also fails some of the tests. More investigation is necessary to determine whether this solution is sound in practice.

return errTooMuch

@seankhliao seankhliao added this to the Unplanned milestone Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants