From: Even Rouault Date: Fri, 28 Jul 2017 20:15:47 +0000 (+0200) Subject: opj_int_ceildiv(): fix int32 overflow. Fixes https://bugs.chromium.org/p/oss-fuzz... X-Git-Tag: v2.2.0~41 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d6654d906c1ae66590b6d600458a91f1ee923de5;p=openjpeg opj_int_ceildiv(): fix int32 overflow. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2494. Credit to OSS Fuzz --- diff --git a/src/lib/openjp2/opj_intmath.h b/src/lib/openjp2/opj_intmath.h index 03a446f1..64c87ed9 100644 --- a/src/lib/openjp2/opj_intmath.h +++ b/src/lib/openjp2/opj_intmath.h @@ -129,7 +129,7 @@ Divide an integer and round upwards static INLINE OPJ_INT32 opj_int_ceildiv(OPJ_INT32 a, OPJ_INT32 b) { assert(b); - return (a + b - 1) / b; + return (OPJ_INT32)(((OPJ_INT64)a + b - 1) / b); } /**