image/gif: GIF files with extraneous 0x00 bytes cause "gif: unknown block type: 0x00" #38853
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes (and it has probably existed for a very long time, possibly forever)
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Tried to use
image/gif
DecodeAll()
on a GIF with extra0x00
byte(s) before the trailer byte0x3b
.Example:
https://play.golang.org/p/vzVJUj4TRgm
What did you expect to see?
The image loads properly (as it does in browsers, ImageMagick, gifsicle and Eye Of GNOME).
What did you see instead?
gif: unknown block type: 0x00
Comments
This is caused by a more strict implementation of the GIF file format than most other programs. We already address this issue for extraneous trailing bytes in the LZW decoder (#16146), but I am also seeing them elsewhere between blocks in real files, generally before the closing trailer byte.
Here are the hex dumps of some example files that I have found:
Here are the images referenced above, they are all very small:
https://drive.google.com/drive/folders/13hKuVy_Kf2MeyWacXLPanwhH2uoIxLUe?usp=sharing
I have a simple solution so I'll put in a PR, but I'm not sure how strict you want to be in handling this (is one extraneous byte OK, but two not OK, for example?).
The text was updated successfully, but these errors were encountered: