aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mpeg4videodec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-06-14 23:49:23 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2017-08-23 13:15:18 +0200
commit6145b27b71148d532bab1420dd88cada9e98c763 (patch)
tree71da065c56d4f6c9720284fe79339b79e9059302 /libavcodec/mpeg4videodec.c
parent4ade217ae016075be70441c9919b82330ab5e9ce (diff)
downloadffmpeg-6145b27b71148d532bab1420dd88cada9e98c763.tar.gz
avcodec/mpeg4videodec: Fix integer overflow in num_sprite_warping_points=2 case
Fixes: runtime error: signed integer overflow: 131072 + 2147352576 cannot be represented in type 'int' Fixes: 2192/clusterfuzz-testcase-minimized-5370387988742144 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 0a87be404ab7e3f47e67e79160dcc9623e36835b) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/mpeg4videodec.c')
-rw-r--r--libavcodec/mpeg4videodec.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index c2844d7764..880d2b2b78 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -281,26 +281,26 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g
ctx->sprite_shift[1] = 0;
break;
case 2:
- sprite_offset[0][0] = (sprite_ref[0][0] * (1 << alpha + rho)) +
- (-r * sprite_ref[0][0] + virtual_ref[0][0]) *
- (-vop_ref[0][0]) +
- (r * sprite_ref[0][1] - virtual_ref[0][1]) *
- (-vop_ref[0][1]) + (1 << (alpha + rho - 1));
- sprite_offset[0][1] = (sprite_ref[0][1] * (1 << alpha + rho)) +
- (-r * sprite_ref[0][1] + virtual_ref[0][1]) *
- (-vop_ref[0][0]) +
- (-r * sprite_ref[0][0] + virtual_ref[0][0]) *
- (-vop_ref[0][1]) + (1 << (alpha + rho - 1));
- sprite_offset[1][0] = ((-r * sprite_ref[0][0] + virtual_ref[0][0]) *
- (-2 * vop_ref[0][0] + 1) +
- (r * sprite_ref[0][1] - virtual_ref[0][1]) *
- (-2 * vop_ref[0][1] + 1) + 2 * w2 * r *
- sprite_ref[0][0] - 16 * w2 + (1 << (alpha + rho + 1)));
- sprite_offset[1][1] = ((-r * sprite_ref[0][1] + virtual_ref[0][1]) *
- (-2 * vop_ref[0][0] + 1) +
- (-r * sprite_ref[0][0] + virtual_ref[0][0]) *
- (-2 * vop_ref[0][1] + 1) + 2 * w2 * r *
- sprite_ref[0][1] - 16 * w2 + (1 << (alpha + rho + 1)));
+ sprite_offset[0][0] = ((int64_t) sprite_ref[0][0] * (1 << alpha + rho)) +
+ ((int64_t) -r * sprite_ref[0][0] + virtual_ref[0][0]) *
+ ((int64_t) -vop_ref[0][0]) +
+ ((int64_t) r * sprite_ref[0][1] - virtual_ref[0][1]) *
+ ((int64_t) -vop_ref[0][1]) + (1 << (alpha + rho - 1));
+ sprite_offset[0][1] = ((int64_t) sprite_ref[0][1] * (1 << alpha + rho)) +
+ ((int64_t) -r * sprite_ref[0][1] + virtual_ref[0][1]) *
+ ((int64_t) -vop_ref[0][0]) +
+ ((int64_t) -r * sprite_ref[0][0] + virtual_ref[0][0]) *
+ ((int64_t) -vop_ref[0][1]) + (1 << (alpha + rho - 1));
+ sprite_offset[1][0] = (((int64_t)-r * sprite_ref[0][0] + virtual_ref[0][0]) *
+ ((int64_t)-2 * vop_ref[0][0] + 1) +
+ ((int64_t) r * sprite_ref[0][1] - virtual_ref[0][1]) *
+ ((int64_t)-2 * vop_ref[0][1] + 1) + 2 * w2 * r *
+ (int64_t) sprite_ref[0][0] - 16 * w2 + (1 << (alpha + rho + 1)));
+ sprite_offset[1][1] = (((int64_t)-r * sprite_ref[0][1] + virtual_ref[0][1]) *
+ ((int64_t)-2 * vop_ref[0][0] + 1) +
+ ((int64_t)-r * sprite_ref[0][0] + virtual_ref[0][0]) *
+ ((int64_t)-2 * vop_ref[0][1] + 1) + 2 * w2 * r *
+ (int64_t) sprite_ref[0][1] - 16 * w2 + (1 << (alpha + rho + 1)));
s->sprite_delta[0][0] = (-r * sprite_ref[0][0] + virtual_ref[0][0]);
s->sprite_delta[0][1] = (+r * sprite_ref[0][1] - virtual_ref[0][1]);
s->sprite_delta[1][0] = (-r * sprite_ref[0][1] + virtual_ref[0][1]);