[pcf] Fix integer overflows (#45985). * src/pcf/pcfread.c (pcf_load_font): Use FT_MulDiv.
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
diff --git a/ChangeLog b/ChangeLog
index 9a2d130..d4f859b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2015-09-17 Werner Lemberg <wl@gnu.org>
+ [pcf] Fix integer overflows (#45985).
+
+ * src/pcf/pcfread.c (pcf_load_font): Use FT_MulDiv.
+
+2015-09-17 Werner Lemberg <wl@gnu.org>
+
[pcf] Use FT_ABS for some property values (#45893).
* src/pcf/pcfread.c (pcf_load_font): Take absolute values for
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index a17b62e..9d8d794 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -1290,7 +1290,7 @@ THE SOFTWARE.
bsize->width = (FT_Short)( ( FT_ABS( prop->value.l ) + 5 ) / 10 );
}
else
- bsize->width = (FT_Short)( bsize->height * 2 / 3 );
+ bsize->width = (FT_Short)FT_MulDiv( bsize->height, 2, 3 );
prop = pcf_find_property( face, "POINT_SIZE" );
if ( prop )
@@ -1339,10 +1339,12 @@ THE SOFTWARE.
{
bsize->y_ppem = bsize->size;
if ( resolution_y )
- bsize->y_ppem = bsize->y_ppem * resolution_y / 72;
+ bsize->y_ppem = FT_MulDiv( bsize->y_ppem, resolution_y, 72 );
}
if ( resolution_x && resolution_y )
- bsize->x_ppem = bsize->y_ppem * resolution_x / resolution_y;
+ bsize->x_ppem = FT_MulDiv( bsize->y_ppem,
+ resolution_x,
+ resolution_y );
else
bsize->x_ppem = bsize->y_ppem;
}