зеркало из https://github.com/golang/image.git
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 <nigeltao@golang.org>
This commit is contained in:
Родитель
f28211f6e1
Коммит
25eff15cb8
|
@ -136,11 +136,10 @@ func (z *Reader) Next() (chunkID FourCC, chunkLen uint32, chunkData io.Reader, e
|
|||
return FourCC{}, 0, nil, z.err
|
||||
}
|
||||
chunkID = FourCC{z.buf[0], z.buf[1], z.buf[2], z.buf[3]}
|
||||
chunkLen = u32(z.buf[4:])
|
||||
z.chunkLen = chunkLen
|
||||
z.padded = chunkLen&1 == 1
|
||||
z.chunkLen = u32(z.buf[4:])
|
||||
z.padded = z.chunkLen&1 == 1
|
||||
z.chunkReader = &chunkReader{z}
|
||||
return chunkID, chunkLen, z.chunkReader, nil
|
||||
return chunkID, z.chunkLen, z.chunkReader, nil
|
||||
}
|
||||
|
||||
type chunkReader struct {
|
||||
|
|
|
@ -144,6 +144,9 @@ func decode(r io.Reader, configOnly bool) (image.Image, image.Config, error) {
|
|||
}, nil
|
||||
}
|
||||
wantAlpha = true
|
||||
|
||||
default:
|
||||
return nil, image.Config{}, errInvalidFormat
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче