avcodec/scpr: Test bx before use

Fixes: out of array access on 32bit
Fixes: 54850/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-5302669294305280

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2023-01-08 20:03:40 +01:00
parent 50c0f2ddd3
commit 1b59de3770
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64

View File

@ -458,6 +458,9 @@ static int decompress_p(AVCodecContext *avctx,
int run, bx = x * 16 + sx1, by = y * 16 + sy1; int run, bx = x * 16 + sx1, by = y * 16 + sy1;
uint32_t r, g, b, clr, ptype = 0; uint32_t r, g, b, clr, ptype = 0;
if (bx >= avctx->width)
return AVERROR_INVALIDDATA;
for (; by < y * 16 + sy2 && by < avctx->height;) { for (; by < y * 16 + sy2 && by < avctx->height;) {
ret = decode_value(s, s->op_model[ptype], 6, 1000, &ptype); ret = decode_value(s, s->op_model[ptype], 6, 1000, &ptype);
if (ret < 0) if (ret < 0)