[cff] Fix value overflow. * src/cff/cffparse.c (cff_parse_fixed_scaled): Implement it.
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
diff --git a/ChangeLog b/ChangeLog
index bf88625..1e8975d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-10-17 Bram Tassyns <BramT@enfocus.com>
+
+ [cff] Fix value overflow.
+
+ * src/cff/cffparse.c (cff_parse_fixed_scaled): Implement it.
+
2012-10-17 Werner Lemberg <wl@gnu.org>
[truetype] Fix Savannah bug #37572.
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 10abcf0..2e93bd3 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -396,9 +396,20 @@
cff_parse_fixed_scaled( FT_Byte** d,
FT_Long scaling )
{
- return **d == 30 ? cff_parse_real( d[0], d[1], scaling, NULL )
- : ( cff_parse_integer( d[0], d[1] ) *
- power_tens[scaling] ) << 16;
+ if ( **d == 30 )
+ return cff_parse_real( d[0], d[1], scaling, NULL );
+ else
+ {
+ FT_Long val = cff_parse_integer( d[0], d[1] ) * power_tens[scaling];
+
+
+ if ( val > 0x7FFF )
+ return 0x7FFFFFFFL;
+ else if ( val < -0x7FFF )
+ return -0x7FFFFFFFL;
+
+ return val << 16;
+ }
}