File tree 2 files changed +7
-1
lines changed 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -349,13 +349,19 @@ func (d *decoder) readGraphicControl() error {
349
349
if _ , err := io .ReadFull (d .r , d .tmp [:6 ]); err != nil {
350
350
return fmt .Errorf ("gif: can't read graphic control: %s" , err )
351
351
}
352
+ if d .tmp [0 ] != 4 {
353
+ return fmt .Errorf ("gif: invalid graphic control extension block size: %d" , d .tmp [0 ])
354
+ }
352
355
flags := d .tmp [1 ]
353
356
d .disposalMethod = (flags & gcDisposalMethodMask ) >> 2
354
357
d .delayTime = int (d .tmp [2 ]) | int (d .tmp [3 ])<< 8
355
358
if flags & gcTransparentColorSet != 0 {
356
359
d .transparentIndex = d .tmp [4 ]
357
360
d .hasTransparentIndex = true
358
361
}
362
+ if d .tmp [5 ] != 0 {
363
+ return fmt .Errorf ("gif: invalid graphic control extension block terminator: %d" , d .tmp [5 ])
364
+ }
359
365
return nil
360
366
}
361
367
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ func TestTransparentIndex(t *testing.T) {
97
97
for transparentIndex := 0 ; transparentIndex < 3 ; transparentIndex ++ {
98
98
if transparentIndex < 2 {
99
99
// Write the graphic control for the transparent index.
100
- b .WriteString ("\x21 \xf9 \x00 \x01 \x00 \x00 " )
100
+ b .WriteString ("\x21 \xf9 \x04 \x01 \x00 \x00 " )
101
101
b .WriteByte (byte (transparentIndex ))
102
102
b .WriteByte (0 )
103
103
}
You can’t perform that action at this time.
0 commit comments