diff mbox

[FFmpeg-devel,1/2] avcodec/wcmv: Fix integer overflows

Message ID 20180925015641.8566-1-michael@niedermayer.cc
State Accepted
Commit a8a98ba9eeedc0c4b5d95e3b61840174cd254bca
Headers show

Commit Message

Michael Niedermayer Sept. 25, 2018, 1:56 a.m. UTC
Fixes: signed integer overflow: 262140 * 65535 cannot be represented in type 'int'
Fixes: 10090/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5691269368512512

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

Comments

Michael Niedermayer Sept. 30, 2018, 8:21 p.m. UTC | #1
On Tue, Sep 25, 2018 at 03:56:40AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 262140 * 65535 cannot be represented in type 'int'
> Fixes: 10090/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5691269368512512
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/wcmv.c | 4 ++++
>  1 file changed, 4 insertions(+)

will apply patchset

[...]
diff mbox

Patch

diff --git a/libavcodec/wcmv.c b/libavcodec/wcmv.c
index 384ceecd32..ebd5ef66f4 100644
--- a/libavcodec/wcmv.c
+++ b/libavcodec/wcmv.c
@@ -113,6 +113,8 @@  static int decode_frame(AVCodecContext *avctx,
             bytestream2_skip(&bgb, 4);
             w = bytestream2_get_le16(&bgb);
             h = bytestream2_get_le16(&bgb);
+            if (x + bpp * (int64_t)w * h > INT_MAX)
+                return AVERROR_INVALIDDATA;
             x += bpp * w * h;
         }
 
@@ -140,6 +142,8 @@  static int decode_frame(AVCodecContext *avctx,
             bytestream2_skip(&gb, 4);
             w = bytestream2_get_le16(&gb);
             h = bytestream2_get_le16(&gb);
+            if (x + bpp * (int64_t)w * h > INT_MAX)
+                return AVERROR_INVALIDDATA;
             x += bpp * w * h;
         }