From 894e1d51cf252a3a38743b2828f190af17d0d31a Mon Sep 17 00:00:00 2001 From: Oleg Oshmyan Date: Sat, 4 Feb 2017 01:35:54 +0200 Subject: ass_lazy_track_init: avoid integer overflow in multiply-divide This is incompatible with VSFilter, so maybe we should later change this to use uint32_t instead. This fixes the multiply-divide if the result fits in int, but `PlayResX = PlayResY * 4LL / 3;` still overflows if PlayResY is close to INT_MAX. This should be addressed in a separate commit. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=533. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=603. --- libass/ass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libass/ass.c b/libass/ass.c index 811a9a7..abfbe7a 100644 --- a/libass/ass.c +++ b/libass/ass.c @@ -1498,7 +1498,7 @@ void ass_lazy_track_init(ASS_Library *lib, ASS_Track *track) ass_msg(lib, MSGL_WARN, "PlayResY undefined, setting to %d", track->PlayResY); } else if (track->PlayResY <= 0) { - track->PlayResY = FFMAX(1, track->PlayResX * 3 / 4); + track->PlayResY = FFMAX(1, track->PlayResX * 3LL / 4); ass_msg(lib, MSGL_WARN, "PlayResY undefined, setting to %d", track->PlayResY); } else if (track->PlayResX <= 0 && track->PlayResY == 1024) { @@ -1506,7 +1506,7 @@ void ass_lazy_track_init(ASS_Library *lib, ASS_Track *track) ass_msg(lib, MSGL_WARN, "PlayResX undefined, setting to %d", track->PlayResX); } else if (track->PlayResX <= 0) { - track->PlayResX = FFMAX(1, track->PlayResY * 4 / 3); + track->PlayResX = FFMAX(1, track->PlayResY * 4LL / 3); ass_msg(lib, MSGL_WARN, "PlayResX undefined, setting to %d", track->PlayResX); } -- cgit v1.2.3