aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-02-27 15:17:12 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2018-07-10 01:18:52 +0200
commitff587292238c4f35036c5208492f34a546bcc6c7 (patch)
treed4b935f7462d3f83e2283644f511e02abe1f62de
parent1c0914e4f34edb02a242d58d3929fdd07a59f211 (diff)
downloadffmpeg-ff587292238c4f35036c5208492f34a546bcc6c7.tar.gz
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@niedermayer.cc> (cherry picked from commit 8ee3265dbe2e85537affe3b3055b00ba8646aa70) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/nuv.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c
index f3270cb19d..1dfa399630 100644
--- a/libavcodec/nuv.c
+++ b/libavcodec/nuv.c
@@ -158,6 +158,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',
@@ -203,6 +204,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 rest of the frameheader.
buf = &buf[12];