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: gif decoding fails on 1x1 pixel image that renders correctly in browser #56771

Open
ccampbell opened this issue Nov 16, 2022 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@ccampbell
Copy link

ccampbell commented Nov 16, 2022

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

go version go1.19.3 darwin/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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ccampbell/Library/Caches/go-build"
GOENV="/Users/ccampbell/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/ccampbell/go/pkg/mod"
GONOPROXY="github.com/fastly"
GONOSUMDB="github.com/fastly"
GOOS="darwin"
GOPATH="/Users/ccampbell/go"
GOPRIVATE="github.com/fastly"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.19.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.19.3/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/ccampbell/Sites/gif-decode-error/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/4b/zg1r6yhs61n89x8d8r02d9zh0000gn/T/go-build925926509=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Playground to reproduce is here:
https://go.dev/play/p/itdNnujIVfy

I included the image as a base64 data url in the playground so you can copy and paste that directly into the browser.

For convenience, I also uploaded it here:
https://test.craig.cloud/test-blank.gif

What did you expect to see?

Expected to see no decode error.

What did you see instead?

decode error: gif: too much image data

The image renders correctly in a browser. Seems perhaps related to #16146, but it is failing at a different point.

The specific failure occurs at

return errTooMuch

@joedian joedian added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 17, 2022
@seankhliao seankhliao added this to the Unplanned milestone Nov 19, 2022
@AlexanderYastrebov
Copy link
Contributor

AlexanderYastrebov commented Nov 20, 2022

~$ echo R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAgFAAGcCQgAOw== | base64 -d | hexdump -C
00000000  47 49 46 38 39 61 01 00  01 00 80 00 00 00 00 00  |GIF89a..........|
00000010  00 00 00 21 f9 04 01 00  00 00 00 2c 00 00 00 00  |...!.......,....|
00000020  01 00 01 00 00 08 05 00  01 9c 09 08 00 3b        |.............;|
0000002e

I think the problem is that the image is of size 1x1 but LZW compressed block (05 00 01 9c 09 08) is of size 5 and contains 2 bytes of data (00 67), see https://go.dev/play/p/KbggFxWzSiP

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