summaryrefslogtreecommitdiff
path: root/vcl/source/fontsubset
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-02-07 16:05:08 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-02-08 15:59:14 +0100
commitf4e32af7450c4e6fa1063aec95ba9df49c055a3b (patch)
tree47468f1a2fb4e47865f437541b5ded09da973845 /vcl/source/fontsubset
parent37e5c9efb19224974a3861eae18e16d6432c6bde (diff)
stay within font bounds
Change-Id: Ie8ed610b71cb1b20963827c2be97155d2d8aa22c Reviewed-on: https://gerrit.libreoffice.org/49369 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/fontsubset')
-rw-r--r--vcl/source/fontsubset/sft.cxx7
1 files changed, 6 insertions, 1 deletions
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index cfad36e35f64..c61c74b672dd 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1563,7 +1563,12 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t )
/* parse the tables */
for (i=0; i<static_cast<int>(t->ntables); i++) {
int nIndex;
- tag = GetUInt32(t->ptr + tdoffset + 12, 16 * i);
+ const sal_uInt32 nStart = tdoffset + 12;
+ const sal_uInt32 nOffset = 16 * i;
+ if (nStart + nOffset + sizeof(sal_uInt32) <= static_cast<sal_uInt32>(t->fsize))
+ tag = GetUInt32(t->ptr + nStart, nOffset);
+ else
+ tag = static_cast<sal_uInt32>(-1);
switch( tag ) {
case T_maxp: nIndex = O_maxp; break;
case T_glyf: nIndex = O_glyf; break;