diff mbox

[FFmpeg-devel,1/4] avcodec/shorten: Sanity check nmeans

Message ID 20180605134517.16413-1-michael@niedermayer.cc
State Accepted
Commit d91a0b503d7a886587281bc1ee42476aa5e89f85
Headers show

Commit Message

Michael Niedermayer June 5, 2018, 1:45 p.m. UTC
Fixes: OOM
Fixes: 8195/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-5179785826271232

The reference software appears to use longs for 32bits and it uses int for nmeans
hinting that the intended maximum size was not 32bit.

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

Comments

Michael Niedermayer June 7, 2018, 5:16 p.m. UTC | #1
On Tue, Jun 05, 2018 at 03:45:14PM +0200, Michael Niedermayer wrote:
> Fixes: OOM
> Fixes: 8195/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-5179785826271232
> 
> The reference software appears to use longs for 32bits and it uses int for nmeans
> hinting that the intended maximum size was not 32bit.
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/shorten.c | 4 ++++
>  1 file changed, 4 insertions(+)

will apply patchset

[...]
diff mbox

Patch

diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index ae0cdfe09d..8aeacfeb31 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -450,6 +450,10 @@  static int read_header(ShortenContext *s)
             return AVERROR_INVALIDDATA;
         }
         s->nmean = get_uint(s, 0);
+        if (s->nmean > 32768U) {
+            av_log(s->avctx, AV_LOG_ERROR, "nmean is: %d\n", s->nmean);
+            return AVERROR_INVALIDDATA;
+        }
 
         skip_bytes = get_uint(s, NSKIPSIZE);
         if ((unsigned)skip_bytes > get_bits_left(&s->gb)/8) {