avcodec/mpeg4videodec: Fix runtime error: signed integer overflow: 134527392 * 16...
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 3 Mar 2017 19:12:20 +0000 (20:12 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 20 May 2017 01:41:33 +0000 (03:41 +0200)
This checks the sprite delta intermediates for overflow
Fixes: 716/clusterfuzz-testcase-4890287480504320

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit fab13bbbcdf92da165f1a6be94fbb8f87fac639a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/mpeg4videodec.c

index b2aa565..0a89dcb 100644 (file)
@@ -388,7 +388,10 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g
         for (i = 0; i < 2; i++) {
             if (llabs(s->sprite_offset[0][i] + s->sprite_delta[i][0] * (w+16LL)) >= INT_MAX ||
                 llabs(s->sprite_offset[0][i] + s->sprite_delta[i][1] * (h+16LL)) >= INT_MAX ||
-                llabs(s->sprite_offset[0][i] + s->sprite_delta[i][0] * (w+16LL) + s->sprite_delta[i][1] * (h+16LL)) >= INT_MAX) {
+                llabs(s->sprite_offset[0][i] + s->sprite_delta[i][0] * (w+16LL) + s->sprite_delta[i][1] * (h+16LL)) >= INT_MAX ||
+                llabs(s->sprite_delta[i][0] * (w+16LL)) >= INT_MAX ||
+                llabs(s->sprite_delta[i][1] * (w+16LL)) >= INT_MAX
+            ) {
                 avpriv_request_sample(s->avctx, "Overflow on sprite points");
                 goto overflow;
             }