Bug 1291217 - Update OTS to version 5.0.1. r=jfkthame

--HG--
extra : rebase_source : 85ea822044fbb0c2ffcec8a460d99e4b751dbff6
This commit is contained in:
Frédéric Wang 2016-08-02 06:32:00 -04:00
parent a4bc3b938a
commit a7fdab6ca8
4 changed files with 30 additions and 19 deletions

View File

@ -2,7 +2,7 @@ This is the Sanitiser for OpenType project, from http://code.google.com/p/ots/.
Our reference repository is https://github.com/khaledhosny/ots/.
Current revision: 99a3b7ff8fb241e0f68a25a41726cc3421d1f9bf
Current revision: 8d70cffebbfa58f67a5c3ed0e9bc84dccdbc5bc0
Upstream files included: LICENSE, src/, include/

View File

@ -282,7 +282,7 @@ bool Parse31012(ots::Font *font,
if (!subtable.ReadU32(&num_groups)) {
return OTS_FAILURE_MSG("can't read number of format 12 subtable groups");
}
if (num_groups == 0 || subtable.remaining() < num_groups * 12) {
if (num_groups == 0 || subtable.remaining() / 12 < num_groups) {
return OTS_FAILURE_MSG("Bad format 12 subtable group count %d", num_groups);
}
@ -356,7 +356,7 @@ bool Parse31013(ots::Font *font,
// We limit the number of groups in the same way as in 3.10.12 tables. See
// the comment there in
if (num_groups == 0 || subtable.remaining() < num_groups * 12) {
if (num_groups == 0 || subtable.remaining() / 12 < num_groups) {
return OTS_FAILURE_MSG("Bad format 13 subtable group count %d", num_groups);
}
@ -464,7 +464,7 @@ bool Parse0514(ots::Font *font,
if (!subtable.ReadU32(&num_ranges)) {
return OTS_FAILURE_MSG("Can't read number of ranges in record %d", i);
}
if (num_ranges == 0 || subtable.remaining() < num_ranges * 4) {
if (num_ranges == 0 || subtable.remaining() / 4 < num_ranges) {
return OTS_FAILURE_MSG("Bad number of ranges (%d) in record %d", num_ranges, i);
}
@ -498,7 +498,7 @@ bool Parse0514(ots::Font *font,
if (!subtable.ReadU32(&num_mappings)) {
return OTS_FAILURE_MSG("Can't read number of mappings in variation selector record %d", i);
}
if (num_mappings == 0 || subtable.remaining() < num_mappings * 5) {
if (num_mappings == 0 || subtable.remaining() / 5 < num_mappings) {
return OTS_FAILURE_MSG("Bad number of mappings (%d) in variation selector record %d", num_mappings, i);
}
@ -658,20 +658,21 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
}
// check if the table is sorted first by platform ID, then by encoding ID.
uint32_t last_id = 0;
for (unsigned i = 0; i < num_tables; ++i) {
uint32_t current_id
= (subtable_headers[i].platform << 24)
+ (subtable_headers[i].encoding << 16)
+ subtable_headers[i].language;
if ((i != 0) && (last_id >= current_id)) {
for (unsigned i = 1; i < num_tables; ++i) {
if (subtable_headers[i - 1].platform > subtable_headers[i].platform ||
(subtable_headers[i - 1].platform == subtable_headers[i].platform &&
(subtable_headers[i - 1].encoding > subtable_headers[i].encoding ||
(subtable_headers[i - 1].encoding == subtable_headers[i].encoding &&
subtable_headers[i - 1].language > subtable_headers[i].language))))
OTS_WARNING("subtable %d with platform ID %d, encoding ID %d, language ID %d "
"following subtable with platform ID %d, encoding ID %d, language ID %d",
i,
(uint8_t)(current_id >> 24), (uint8_t)(current_id >> 16), (uint8_t)(current_id),
(uint8_t)(last_id >> 24), (uint8_t)(last_id >> 16), (uint8_t)(last_id));
}
last_id = current_id;
subtable_headers[i].platform,
subtable_headers[i].encoding,
subtable_headers[i].language,
subtable_headers[i - 1].platform,
subtable_headers[i - 1].encoding,
subtable_headers[i - 1].language);
}
// Now, verify that all the lengths are sane

View File

@ -95,9 +95,14 @@ bool ParseScriptTable(const ots::Font *font,
// The spec requires a script table for 'DFLT' tag must contain non-NULL
// |offset_default_lang_sys| and |lang_sys_count| == 0
if (tag == kScriptTableTagDflt &&
(offset_default_lang_sys == 0 || lang_sys_count != 0)) {
return OTS_FAILURE_MSG("DFLT table doesn't satisfy the spec. for script tag %c%c%c%c", OTS_UNTAG(tag));
// https://www.microsoft.com/typography/otspec/chapter2.htm
if (tag == kScriptTableTagDflt) {
if (offset_default_lang_sys == 0) {
return OTS_FAILURE_MSG("DFLT script doesn't satisfy the spec. DefaultLangSys is NULL");
}
if (lang_sys_count != 0) {
return OTS_FAILURE_MSG("DFLT script doesn't satisfy the spec. LangSysCount is not zero: %d", lang_sys_count);
}
}
const unsigned lang_sys_record_end =

View File

@ -448,6 +448,11 @@ bool ParseMathGlyphConstructionSequence(const ots::Font *font,
uint16_t offset_coverage,
uint16_t glyph_count,
const unsigned sequence_end) {
// Zero glyph count, nothing to parse.
if (!glyph_count) {
return true;
}
// Check coverage table.
if (offset_coverage < sequence_end || offset_coverage >= length) {
return OTS_FAILURE();