summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorWerner Lemberg <wl@gnu.org>2017-05-31 16:16:50 +0200
committerWerner Lemberg <wl@gnu.org>2017-05-31 16:16:50 +0200
commite66d7300fec2f9fc60e43a924af1972b07ee316b (patch)
tree22a117592393875eaca98d4780ce266abac8f65f /include
parent9b710cd56eb66c379686e82d7fe371c212aebc37 (diff)
downloadfreetype2-e66d7300fec2f9fc60e43a924af1972b07ee316b.tar.gz
[cff] 32bit integer overflow run-time errors 2/2 (#46149).
This commit handles the new engine. * include/freetype/internal/ftcalc.h (OVERFLOW_ADD_INT32, OVERFLOW_SUB_INT32, OVERFLOW_MUL_INT32, NEG_INT, NEG_LONG, NEG_INT32): New macros. * src/cff/cf2ft.c (cf2_getScaleAndHintFlag): Use OVERFLOW_ADD_INT32. * src/cff/cf2hints.c (cf2_getWindingMomentum, cf2_hint_init, cf2_hintmap_map, cf2_glyphpath_hintPoint, cf2_glyphpath_computeIntersection, cf2_glyphpath_computeOffset, cf2_glyphpath_lineTo, cf2_glyphpath_curveTo): Use OVERFLOW_ADD_INT32, OVERFLOW_SUB_INT32, OVERFLOW_MUL_INT32, and NEG_INT32 where appropriate. * src/cff/cf2intrp.c (cf2_doFlex, cf2_doBlend, cf2_interpT2CharString): Ditto. Also add some other code where needed to avoid overflow.
Diffstat (limited to 'include')
-rw-r--r--include/freetype/internal/ftcalc.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/freetype/internal/ftcalc.h b/include/freetype/internal/ftcalc.h
index 1cd32c892..2b040feea 100644
--- a/include/freetype/internal/ftcalc.h
+++ b/include/freetype/internal/ftcalc.h
@@ -423,6 +423,8 @@ FT_BEGIN_HEADER
(FT_Int)( (FT_UInt)(a) - (FT_UInt)(b) )
#define OVERFLOW_MUL_INT( a, b ) \
(FT_Int)( (FT_UInt)(a) * (FT_UInt)(b) )
+#define NEG_INT( a ) \
+ (FT_Int)( -(FT_UInt)(a) )
#define OVERFLOW_ADD_LONG( a, b ) \
(FT_Long)( (FT_ULong)(a) + (FT_ULong)(b) )
@@ -430,6 +432,17 @@ FT_BEGIN_HEADER
(FT_Long)( (FT_ULong)(a) - (FT_ULong)(b) )
#define OVERFLOW_MUL_LONG( a, b ) \
(FT_Long)( (FT_ULong)(a) * (FT_ULong)(b) )
+#define NEG_LONG( a ) \
+ (FT_Long)( -(FT_ULong)(a) )
+
+#define OVERFLOW_ADD_INT32( a, b ) \
+ (FT_Int32)( (FT_UInt32)(a) + (FT_UInt32)(b) )
+#define OVERFLOW_SUB_INT32( a, b ) \
+ (FT_Int32)( (FT_UInt32)(a) - (FT_UInt32)(b) )
+#define OVERFLOW_MUL_INT32( a, b ) \
+ (FT_Int32)( (FT_UInt32)(a) * (FT_UInt32)(b) )
+#define NEG_INT32( a ) \
+ (FT_Int32)( -(FT_UInt32)(a) )
FT_END_HEADER