diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-06-06 10:00:21 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-06-06 10:00:21 +0100 |
commit | 623b4e3e10ed8afe8807f2599e03f748c0d392d2 (patch) | |
tree | be776ecb393d87910a57bbd2ba325549b9c9c2d8 /vcl/source | |
parent | b4a0104849eeecb7779fda41116c92c362759882 (diff) |
improve this sanity check
Change-Id: If202723412b2bf7acf7dcd2709886f89df9d7940
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/fontsubset/sft.cxx | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index 8b00a3024a19..2fdd6ea0e705 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -1226,16 +1226,19 @@ static void FindCmap(TrueTypeFont *ttf) sal_uInt32 ThreeSix = 0; /* MS Johab */ for (i = 0; i < ncmaps; i++) { - sal_uInt32 offset; - sal_uInt16 pID, eID; - /* sanity check, cmap entry must lie within table */ - if( i*8+4 > table_size ) + sal_uInt32 nLargestFixedOffsetPos = 8 + i * 8; + sal_uInt32 nMinSize = nLargestFixedOffsetPos + sizeof(sal_uInt32); + if (nMinSize > table_size) + { + SAL_WARN( "vcl.fonts", "Font " << OUString::createFromAscii(ttf->fname) << " claimed to have " + << ncmaps << " cmaps, but only space for " << i); break; + } - pID = GetUInt16(table, 4 + i * 8, 1); - eID = GetUInt16(table, 6 + i * 8, 1); - offset = GetUInt32(table, 8 + i * 8, 1); + sal_uInt16 pID = GetUInt16(table, 4 + i * 8, 1); + sal_uInt16 eID = GetUInt16(table, 6 + i * 8, 1); + sal_uInt32 offset = GetUInt32(table, nLargestFixedOffsetPos, 1); /* sanity check, cmap must lie within file */ if( (table - ttf->ptr) + offset > (sal_uInt32)ttf->fsize ) |