diff mbox series

[FFmpeg-devel,2/2] avcodec/rscc: Check inflated_buf size whan it is used

Message ID 20201122153733.26513-2-michael@niedermayer.cc
State Accepted
Commit a5ed6da9bdbe32408aabe1c75e4b55fcaeec1e9b
Headers show
Series [FFmpeg-devel,1/2] avformat/utils: Change compute_chapters_end() from O(n²) to O(n log n) | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer Nov. 22, 2020, 3:37 p.m. UTC
Fixes: out of array access
Fixes: 27434/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-5196757675540480

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
---
 libavcodec/rscc.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Michael Niedermayer Feb. 4, 2021, 4:24 p.m. UTC | #1
On Sun, Nov 22, 2020 at 04:37:33PM +0100, Michael Niedermayer wrote:
> Fixes: out of array access
> Fixes: 27434/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-5196757675540480
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> ---
>  libavcodec/rscc.c | 4 ++++
>  1 file changed, 4 insertions(+)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c
index bd0520950f..07a7c3dca3 100644
--- a/libavcodec/rscc.c
+++ b/libavcodec/rscc.c
@@ -300,6 +300,10 @@  static int rscc_decode_frame(AVCodecContext *avctx, void *data,
             ret = AVERROR_INVALIDDATA;
             goto end;
         }
+        if (ctx->inflated_size < pixel_size) {
+            ret = AVERROR_INVALIDDATA;
+            goto end;
+        }
         ret = uncompress(ctx->inflated_buf, &len, gbc->buffer, packed_size);
         if (ret) {
             av_log(avctx, AV_LOG_ERROR, "Pixel deflate error %d.\n", ret);