diff mbox series

[FFmpeg-devel] avcodec/scpr3: Check bx

Message ID 20230116101433.10989-1-michael@niedermayer.cc
State Accepted
Commit cc7e984a05b28dcfaaaad95afa061be71b4ba7fc
Headers show
Series [FFmpeg-devel] avcodec/scpr3: Check bx | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Michael Niedermayer Jan. 16, 2023, 10:14 a.m. UTC
Fixes: Out of array access
Fixes: 55102/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-4877396618903552

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/scpr3.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Michael Niedermayer Jan. 17, 2023, 11:52 a.m. UTC | #1
On Mon, Jan 16, 2023 at 11:14:33AM +0100, Michael Niedermayer wrote:
> Fixes: Out of array access
> Fixes: 55102/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-4877396618903552
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/scpr3.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply as this is the same as the scpr.c case


[...]
diff mbox series

Patch

diff --git a/libavcodec/scpr3.c b/libavcodec/scpr3.c
index d9ea6af1c1..5271717ac7 100644
--- a/libavcodec/scpr3.c
+++ b/libavcodec/scpr3.c
@@ -1167,6 +1167,9 @@  static int decompress_p3(AVCodecContext *avctx,
                 int run, bx = x * 16 + sx1, by = y * 16 + sy1;
                 uint32_t clr, ptype = 0, r, g, b;
 
+                if (bx >= avctx->width)
+                    return AVERROR_INVALIDDATA;
+
                 for (; by < y * 16 + sy2 && by < avctx->height;) {
                     ret = decode_value3(s, 5, &s->op_model3[ptype].cntsum,
                                         s->op_model3[ptype].freqs[0],