aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-04-06 23:14:08 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-04-08 22:55:16 +0200
commitaeba1a4c20cf37f1cbbd6338783e18cfb463b0c7 (patch)
tree6fcf63d7d0c6ef4ae201daa8637044e95e3db53b
parentd22550dd61003ffefc1a7738b2c14916083116a9 (diff)
downloadffmpeg-aeba1a4c20cf37f1cbbd6338783e18cfb463b0c7.tar.gz
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 caaf4633117f77a545975dac18e85b8fcdbc9ce7) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/msp2dec.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/libavcodec/msp2dec.c b/libavcodec/msp2dec.c
index cc548d218a..16c5ac6f02 100644
--- a/libavcodec/msp2dec.c
+++ b/libavcodec/msp2dec.c
@@ -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 {