summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-02-07 16:44:43 +0000
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-06-01 14:47:51 +0200
commit0939dc7eb4de0f4f2c323322cbe7f887937335c1 (patch)
treeb6766b034abe0b453b10769dea802293f4013ba0
parent038175f960401e0be0a26e74c9c0c5ff052c31fd (diff)
check O_hhea and O_vhea sizes
Change-Id: I82e47732815f0112801c8c3a3e5b0b09ac25610a Reviewed-on: https://gerrit.libreoffice.org/49439 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--vcl/source/fontsubset/sft.cxx10
1 files changed, 7 insertions, 3 deletions
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index d97be8071272..b34037ebdba1 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1548,8 +1548,10 @@ int OpenTTFontBuffer(const void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, T
static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t )
{
- if (t->fsize < 4)
+ if (t->fsize < 4) {
+ CloseTTFont(t);
return SF_TTFORMAT;
+ }
int i;
sal_uInt32 length, tag;
sal_uInt32 tdoffset = 0; /* offset to TableDirectory in a TTC file. For TTF files is 0 */
@@ -1730,10 +1732,12 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t )
}
table = getTable(t, O_hhea);
- t->numberOfHMetrics = (table != nullptr) ? GetUInt16(table, 34, 1) : 0;
+ table_size = getTableSize(t, O_hhea);
+ t->numberOfHMetrics = (table && table_size >= 36) ? GetUInt16(table, 34, 1) : 0;
table = getTable(t, O_vhea);
- t->numOfLongVerMetrics = (table != nullptr) ? GetUInt16(table, 34, 1) : 0;
+ table_size = getTableSize(t, O_vhea);
+ t->numOfLongVerMetrics = (table && table_size >= 36) ? GetUInt16(table, 34, 1) : 0;
GetNames(t);
FindCmap(t);