Skip to content

Commit 0abe377

Browse files
committed
webp: fix panic in case of invalid chunkID
At the time of decoding webp file, if chunkID is not one of {'ALPH', 'VP8', 'VP8L', 'VP8X'} return errInvalidFormat Fixes golang/go#10384 Change-Id: I167909b5ddef174d161f806297a08fac6aabcf19 Reviewed-on: https://go-review.googlesource.com/9839 Reviewed-by: Nigel Tao <[email protected]>
1 parent f0ab08c commit 0abe377

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

riff/riff.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,10 @@ func (z *Reader) Next() (chunkID FourCC, chunkLen uint32, chunkData io.Reader, e
136136
return FourCC{}, 0, nil, z.err
137137
}
138138
chunkID = FourCC{z.buf[0], z.buf[1], z.buf[2], z.buf[3]}
139-
chunkLen = u32(z.buf[4:])
140-
z.chunkLen = chunkLen
141-
z.padded = chunkLen&1 == 1
139+
z.chunkLen = u32(z.buf[4:])
140+
z.padded = z.chunkLen&1 == 1
142141
z.chunkReader = &chunkReader{z}
143-
return chunkID, chunkLen, z.chunkReader, nil
142+
return chunkID, z.chunkLen, z.chunkReader, nil
144143
}
145144

146145
type chunkReader struct {

webp/decode.go

+3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ func decode(r io.Reader, configOnly bool) (image.Image, image.Config, error) {
144144
}, nil
145145
}
146146
wantAlpha = true
147+
148+
default:
149+
return nil, image.Config{}, errInvalidFormat
147150
}
148151
}
149152
}

0 commit comments

Comments
 (0)