Browse code

avcodec/shorten: Sanity check maxnlpc

Fixes OOM
Fixes: 2131/clusterfuzz-testcase-minimized-4718045157130240

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 e77ddd31a8e14bcf5eccd6008d866ae90b4b0d4c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Michael Niedermayer authored on 2017/06/09 09:16:54
Showing 1 changed files
... ...
@@ -436,6 +436,10 @@ static int read_header(ShortenContext *s)
436 436
         s->blocksize = blocksize;
437 437
 
438 438
         maxnlpc  = get_uint(s, LPCQSIZE);
439
+        if (maxnlpc > 1024U) {
440
+            av_log(s->avctx, AV_LOG_ERROR, "maxnlpc is: %d\n", maxnlpc);
441
+            return AVERROR_INVALIDDATA;
442
+        }
439 443
         s->nmean = get_uint(s, 0);
440 444
 
441 445
         skip_bytes = get_uint(s, NSKIPSIZE);