diff mbox

[FFmpeg-devel,1/3] avcodec/escape124: Check depth against num_superblocks

Message ID 20170520210104.4943-1-michael@niedermayer.cc
State Accepted
Commit da617408c80afd2ea67a175fabc0ba546b9b04bc
Headers show

Commit Message

Michael Niedermayer May 20, 2017, 9:01 p.m. UTC
Fixes: runtime error: left shift of 66184 by 15 places cannot be represented in type 'int'
Fixes: 1707/clusterfuzz-testcase-minimized-6502767008940032

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

Comments

Michael Niedermayer May 22, 2017, 3:40 p.m. UTC | #1
On Sat, May 20, 2017 at 11:01:02PM +0200, Michael Niedermayer wrote:
> Fixes: runtime error: left shift of 66184 by 15 places cannot be represented in type 'int'
> Fixes: 1707/clusterfuzz-testcase-minimized-6502767008940032
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/escape124.c | 5 +++++
>  1 file changed, 5 insertions(+)

applied

[...]
diff mbox

Patch

diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c
index c3174ce6ef..eb051eba54 100644
--- a/libavcodec/escape124.c
+++ b/libavcodec/escape124.c
@@ -267,6 +267,11 @@  static int escape124_decode_frame(AVCodecContext *avctx,
                     cb_size = s->num_superblocks << cb_depth;
                 }
             }
+            if (s->num_superblocks >= INT_MAX >> cb_depth) {
+                av_log(avctx, AV_LOG_ERROR, "Depth or num_superblocks are too large\n");
+                return AVERROR_INVALIDDATA;
+            }
+
             av_freep(&s->codebooks[i].blocks);
             s->codebooks[i] = unpack_codebook(&gb, cb_depth, cb_size);
             if (!s->codebooks[i].blocks)