6 Commits

Author SHA1 Message Date
Raph Levien
3034e8b4ab Reject fonts with invalid ranges in cmap
am: ca8ac8acda

* commit 'ca8ac8acdad662230ae37998c6c4091bb39402b6':
  Reject fonts with invalid ranges in cmap
2016-01-15 21:28:10 +00:00
Raph Levien
ca8ac8acda Reject fonts with invalid ranges in cmap
A corrupt or malicious font may have a negative size in its cmap
range, which in turn could lead to memory corruption. This patch
detects the case and rejects the font, and also includes an assertion
in the sparse bit set implementation if we missed any such case.

External issue:
https://code.google.com/p/android/issues/detail?id=192618

Bug: 26413177
Change-Id: Icc0c80e4ef389abba0964495b89aa0fae3e9f4b2
2016-01-07 21:39:25 +00:00
Raph Levien
998293f985 Avoid integer overflows in parsing fonts
am: 6299a6ba13

* commit '6299a6ba13906c695f7a4f6748f7bc5856a110e5':
  Avoid integer overflows in parsing fonts
2015-12-08 19:17:40 +00:00
Raph Levien
6299a6ba13 Avoid integer overflows in parsing fonts
A malformed TTF can cause size calculations to overflow. This patch
checks the maximum reasonable value so that the total size fits in 32
bits. It also adds some explicit casting to avoid possible technical
undefined behavior when parsing sized unsigned values.

Bug: 25645298
Change-Id: Id4716132041a6f4f1fbb73ec4e445391cf7d9616
(cherry picked from commit 183c9ec2800baa2ce099ee260c6cbc6121cf1274)
2015-12-07 17:58:12 +00:00
Raph Levien
5f11abd31f Silently ignore invalid rangeOffset values
Some fonts contain a cmap segment for char 0xffff that contains an
invalid rangeOffset. This was rejected by the existing code, which
means the font is considered to have empty Unicode coverage. This patch
just discards the invalid segment (consistent with OpenType Sanitizer),
making the custom font display.

Bug: 18106256
Change-Id: Icc8616a3030f80e62db906332be64d434ae72ea2
2014-10-23 23:31:42 +00:00
Raph Levien
9cc9bbe146 Initial commit of Minikin library
This is the initial draft of Minikin, a library intended to perform text
layout functions. This version does basic weight selection and font runs
for scripts, and also has a simple renderer for drawing into bitmaps,
but is lacking measurement, line breaking, and a number of other
important features. It also lacks caching and other performance
refinements.

Change-Id: I789a2e47d11d71202dc84b4751b51a5e2cd9c451
2013-04-25 12:23:57 -07:00