* include/freetype/internal/ftcalc.h: Add macros for handling harmless over-/underflowing `FT_Int' values. * src/sfnt/sfdriver.c (fixed2float): Fix negation of `(int)(-2147483648)'. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9423
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
diff --git a/ChangeLog b/ChangeLog
index 9ce6368..da80b13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2018-07-16 Armin Hasitzka <prince.cherusker@gmail.com>
+
+ * include/freetype/internal/ftcalc.h: Add macros for handling
+ harmless over-/underflowing `FT_Int' values.
+
+ * src/sfnt/sfdriver.c (fixed2float): Fix negation of
+ `(int)(-2147483648)'.
+
+ Reported as
+
+ https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9423
+
2018-07-16 Werner Lemberg <wl@gnu.org>
* src/truetype/ttgxvar.c (tt_set_mm_blend): Fix off-by-one error.
diff --git a/include/freetype/internal/ftcalc.h b/include/freetype/internal/ftcalc.h
index 02467e9..733b674 100644
--- a/include/freetype/internal/ftcalc.h
+++ b/include/freetype/internal/ftcalc.h
@@ -462,6 +462,15 @@ FT_BEGIN_HEADER
*
* Use with care!
*/
+#define ADD_INT( a, b ) \
+ (FT_Int)( (FT_UInt)(a) + (FT_UInt)(b) )
+#define SUB_INT( a, b ) \
+ (FT_Int)( (FT_UInt)(a) - (FT_UInt)(b) )
+#define MUL_INT( a, b ) \
+ (FT_Int)( (FT_UInt)(a) * (FT_UInt)(b) )
+#define NEG_INT( a ) \
+ (FT_Int)( (FT_UInt)0 - (FT_UInt)(a) )
+
#define ADD_LONG( a, b ) \
(FT_Long)( (FT_ULong)(a) + (FT_ULong)(b) )
#define SUB_LONG( a, b ) \
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index cd2d809..ae6d6cd 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -677,7 +677,7 @@
if ( fixed < 0 )
{
*p++ = '-';
- fixed = -fixed;
+ fixed = NEG_INT( fixed );
}
int_part = ( fixed >> 16 ) & 0xFFFF;