diff mbox

[FFmpeg-devel] avcodec/msmpeg4dec: Skip frame if its smaller than 1/8 of the minimal size

Message ID 20181129013210.15887-1-michael@niedermayer.cc
State Accepted
Commit 09ec182864d41c990bc18f620eabb77444aeff57
Headers show

Commit Message

Michael Niedermayer Nov. 29, 2018, 1:32 a.m. UTC
Frames that small are not valid and of limited use for error concealment, while
being very computationally intensive to process.

Fixes: Timeout
Fixes: 11318/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSMPEG4V1_fuzzer-5710884555456512

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

Comments

Michael Niedermayer Dec. 4, 2018, 10:30 p.m. UTC | #1
On Thu, Nov 29, 2018 at 02:32:10AM +0100, Michael Niedermayer wrote:
> Frames that small are not valid and of limited use for error concealment, while
> being very computationally intensive to process.
> 
> Fixes: Timeout
> Fixes: 11318/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSMPEG4V1_fuzzer-5710884555456512
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/msmpeg4dec.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

will apply this and the othar patch

[...]
diff mbox

Patch

diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index 457a37e745..16b67192b5 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -412,6 +412,14 @@  int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
 {
     int code;
 
+    // at minimum one bit per macroblock is required at least in a valid frame,
+    // we discard frames much smaller than this. Frames smaller than 1/8 of the
+    // smallest "black/skip" frame generally contain not much recoverable content
+    // while at the same time they have the highest computational requirements
+    // per byte
+    if (get_bits_left(&s->gb) * 8LL < (s->width+15)/16 * ((s->height+15)/16))
+        return AVERROR_INVALIDDATA;
+
     if(s->msmpeg4_version==1){
         int start_code = get_bits_long(&s->gb, 32);
         if(start_code!=0x00000100){