diff --git a/gfx/ots/README.mozilla b/gfx/ots/README.mozilla index 221ddc4db90..c32e8db82db 100644 --- a/gfx/ots/README.mozilla +++ b/gfx/ots/README.mozilla @@ -1,6 +1,6 @@ This is the Sanitiser for OpenType project, from http://code.google.com/p/ots/. -Current revision: r91 +Current revision: r92 Applied local patches: ots-fix-vc10.patch - workaround for VS10 STL wrappers (bug 602558) diff --git a/gfx/ots/src/ots.cc b/gfx/ots/src/ots.cc index 07a980f076f..25b9ed26733 100644 --- a/gfx/ots/src/ots.cc +++ b/gfx/ots/src/ots.cc @@ -185,7 +185,9 @@ bool IsValidVersionTag(uint32_t tag) { tag == Tag("typ1"); } -bool ProcessGeneric(ots::OpenTypeFile *header, ots::OTSStream *output, +bool ProcessGeneric(ots::OpenTypeFile *header, + uint32_t signature, + ots::OTSStream *output, const uint8_t *data, size_t length, const std::vector& tables, ots::Buffer& file); @@ -263,7 +265,8 @@ bool ProcessTTF(ots::OpenTypeFile *header, tables.push_back(table); } - return ProcessGeneric(header, output, data, length, tables, file); + return ProcessGeneric(header, header->version, output, data, length, + tables, file); } bool ProcessWOFF(ots::OpenTypeFile *header, @@ -421,10 +424,11 @@ bool ProcessWOFF(ots::OpenTypeFile *header, return OTS_FAILURE_MSG_HDR("file length mismatch (trailing junk?)"); } - return ProcessGeneric(header, output, data, length, tables, file); + return ProcessGeneric(header, woff_tag, output, data, length, tables, file); } -bool ProcessGeneric(ots::OpenTypeFile *header, ots::OTSStream *output, +bool ProcessGeneric(ots::OpenTypeFile *header, uint32_t signature, + ots::OTSStream *output, const uint8_t *data, size_t length, const std::vector& tables, ots::Buffer& file) { @@ -485,10 +489,11 @@ bool ProcessGeneric(ots::OpenTypeFile *header, ots::OTSStream *output, } // since we required that the file be < 1GB in length, and that the table // length is < 1GB, the following addtion doesn't overflow - const uint32_t end_byte = tables[i].offset + tables[i].length; - // Some fonts which are automatically generated by a font generator - // called TTX seems not to add 0-padding to the final table. It might be - // ok to accept these fonts so we round up the length of the font file. + uint32_t end_byte = tables[i].offset + tables[i].length; + // Tables in the WOFF file must be aligned 4-byte boundary. + if (signature == Tag("wOFF")) { + end_byte = Round4(end_byte); + } if (!end_byte || end_byte > length) { return OTS_FAILURE_MSG_TAG("table overruns end of file", &tables[i].tag); }