[FFmpeg-cvslog] avcodec/nuv: Check for minimum input size for uncomprssed and rtjpeg

Michael Niedermayer git at videolan.org
Mon Mar 12 02:33:29 EET 2018


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Tue Feb 27 15:17:12 2018 +0100| [8ee3265dbe2e85537affe3b3055b00ba8646aa70] | committer: Michael Niedermayer

avcodec/nuv: Check for minimum input size for uncomprssed and rtjpeg

Fixes: Timeout
Fixes: 6297/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NUV_fuzzer-4882404863901696

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8ee3265dbe2e85537affe3b3055b00ba8646aa70
---

 libavcodec/nuv.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c
index ad6c029e50..8d806dbbff 100644
--- a/libavcodec/nuv.c
+++ b/libavcodec/nuv.c
@@ -161,6 +161,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     int orig_size      = buf_size;
     int keyframe, ret;
     int size_change = 0;
+    int minsize = 0;
     int result, init_frame = !avctx->frame_number;
     enum {
         NUV_UNCOMPRESSED  = '0',
@@ -206,6 +207,16 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
         keyframe = 1;
         break;
     }
+    switch (comptype) {
+    case NUV_UNCOMPRESSED:
+        minsize = c->width * c->height * 3 / 2;
+        break;
+    case NUV_RTJPEG:
+        minsize = c->width/16 * (c->height/16) * 6;
+        break;
+    }
+    if (buf_size < minsize / 4)
+        return AVERROR_INVALIDDATA;
 retry:
     // Skip the rest of the frame header.
     buf       = &buf[12];



More information about the ffmpeg-cvslog mailing list