ftcalc.h: Avoid left-shift of negative numbers.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2055

* include/freetype/internal/ftcalc.h (INT_TO_F26DOT6,
INT_TO_F2DOT14, INT_TO_FIXED, F2DOT14_TO_FIXED): Use multiplication.
This commit is contained in:
Werner Lemberg 2017-06-03 06:13:10 +02:00
parent 0716c6ab7a
commit c5a225413f
2 changed files with 15 additions and 4 deletions

View File

@ -1,3 +1,14 @@
2017-06-03 Werner Lemberg <wl@gnu.org>
ftcalc.h: Avoid left-shift of negative numbers.
Reported as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2055
* include/freetype/internal/ftcalc.h (INT_TO_F26DOT6,
INT_TO_F2DOT14, INT_TO_FIXED, F2DOT14_TO_FIXED): Use multiplication.
2017-06-02 Werner Lemberg <wl@gnu.org>
[cff] Even more integer overflows.

View File

@ -399,10 +399,10 @@ FT_BEGIN_HEADER
#endif /* 0 */
#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 )
#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 )
#define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 )
#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 )
#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) * 64 ) /* << 6 */
#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) * 16384 ) /* << 14 */
#define INT_TO_FIXED( x ) ( (FT_Long)(x) * 65536 ) /* << 16 */
#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) * 4 ) /* << 2 */
#define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 )
#define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \