avcodec/msp2dec: Check available space in RLE decoder

Fixes: out of array read
Fixes: 32968/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSP2_fuzzer-5315296027082752

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit caaf463311)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2021-04-06 23:14:08 +02:00
parent d22550dd61
commit aeba1a4c20
1 changed files with 1 additions and 0 deletions

View File

@ -71,6 +71,7 @@ static int msp2_decode_frame(AVCodecContext *avctx,
while (bytestream2_get_bytes_left(&gb) && x < width) {
int size = bytestream2_get_byte(&gb);
if (size) {
size = FFMIN(size, bytestream2_get_bytes_left(&gb));
memcpy(p->data[0] + y * p->linesize[0] + x, gb.buffer, FFMIN(size, width - x));
bytestream2_skip(&gb, size);
} else {