File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ proc decodeGif*(data: string): Gif {.raises: [PixieError].} =
4141 bgColorIndex = data.readUint8 (11 ).int
4242 pixelAspectRatio = data.readUint8 (12 )
4343
44- if bgColorIndex > globalColorTableSize:
44+ if bgColorIndex >= globalColorTableSize:
4545 failInvalid ()
4646
4747 if pixelAspectRatio != 0 :
Original file line number Diff line number Diff line change @@ -35,3 +35,20 @@ block:
3535 decodeGif (readFile (" tests/fileformats/gif/newtons_cradle.gif" ))
3636 doAssert animatedGif.frames.len == 36
3737 doAssert animatedGif.intervals.len == animatedGif.frames.len
38+
39+ block :
40+ proc addLe16 (data: var string , value: int ) =
41+ data.add (char (value and 0x ff ))
42+ data.add (char ((value shr 8 ) and 0x ff ))
43+
44+ var payload = " GIF89a"
45+ payload.addLe16 (1 )
46+ payload.addLe16 (1 )
47+ payload.add (char (0x 80 )) # Global color table present, size = 2 entries.
48+ payload.add (char (0x 02 )) # One past the last valid color table index.
49+ payload.add (char (0x 00 ))
50+ payload.add (" \x00\x00\x00\xff\xff\xff " )
51+ payload.add (char (0x 3b ))
52+
53+ doAssertRaises PixieError :
54+ discard decodeGif (payload)
You can’t perform that action at this time.
0 commit comments