diff mbox series

[FFmpeg-devel,6/8] avcodec/cri: Use ff_set_dimensions()

Message ID 20210201223116.11378-6-michael@niedermayer.cc
State Accepted
Commit 2a0d17c4d1f7f5539b8bbad90cca1eab45780982
Headers show
Series [FFmpeg-devel,1/8] avcodec/cbs_sei_syntax_template: Check for non negativity before setting size_t bits_left | 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 Feb. 1, 2021, 10:31 p.m. UTC
Fixes: out of memory
Fixes: 29985/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-6424425392111616

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

Comments

Paul B Mahol Feb. 1, 2021, 10:43 p.m. UTC | #1
LGTM
Michael Niedermayer Feb. 2, 2021, 10:30 a.m. UTC | #2
On Mon, Feb 01, 2021 at 11:43:20PM +0100, Paul B Mahol wrote:
> LGTM

will applly
thx
diff mbox series

Patch

diff --git a/libavcodec/cri.c b/libavcodec/cri.c
index 2d33b54e42..3312606b75 100644
--- a/libavcodec/cri.c
+++ b/libavcodec/cri.c
@@ -184,6 +184,7 @@  static int cri_decode_frame(AVCodecContext *avctx, void *data,
         char codec_name[1024];
         uint32_t key, length;
         float framerate;
+        int width, height;
 
         key    = bytestream2_get_le32(gb);
         length = bytestream2_get_le32(gb);
@@ -199,11 +200,14 @@  static int cri_decode_frame(AVCodecContext *avctx, void *data,
         case 100:
             if (length < 16)
                 return AVERROR_INVALIDDATA;
-            avctx->width   = bytestream2_get_le32(gb);
-            avctx->height  = bytestream2_get_le32(gb);
+            width   = bytestream2_get_le32(gb);
+            height  = bytestream2_get_le32(gb);
             s->color_model = bytestream2_get_le32(gb);
             if (bytestream2_get_le32(gb) != 1)
                 return AVERROR_INVALIDDATA;
+            ret = ff_set_dimensions(avctx, width, height);
+            if (ret < 0)
+                return ret;
             length -= 16;
             goto skip;
         case 101: