1
From 2cdc4562f873237f1c77d43540537c7a721d3fd8 Mon Sep 17 00:00:00 2001
2
From: Dave Arnold <darnold@adobe.com>
3
Date: Thu, 04 Dec 2014 05:10:16 +0000
4
Subject: [cff] Fix Savannah bug #43661.
6
* src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdHSTEM,
7
cf2_cmdVSTEM, cf2_cmdHINTMASK>: Don't append to stem arrays after
8
hintmask is constructed.
10
* src/cff/cf2hints.c (cf2_hintmap_build): Add defensive code to
11
avoid reading past end of hintmask.
13
diff --git a/src/cff/cf2hints.c b/src/cff/cf2hints.c
14
index 81049f4..28a892b 100644
15
--- a/src/cff/cf2hints.c
16
+++ b/src/cff/cf2hints.c
18
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
20
/* use the hStem hints only, which are first in the mask */
21
- /* TODO: compare this to cffhintmaskGetBitCount */
22
bitCount = cf2_arrstack_size( hStemHintArray );
24
+ /* Defense-in-depth. Should never return here. */
25
+ if ( bitCount > hintMask->bitCount )
28
/* synthetic embox hints get highest priority */
29
if ( font->blues.doEmBoxHints )
31
diff --git a/src/cff/cf2intrp.c b/src/cff/cf2intrp.c
32
index 5610917..a269606 100644
33
--- a/src/cff/cf2intrp.c
34
+++ b/src/cff/cf2intrp.c
37
/* never add hints after the mask is computed */
38
if ( cf2_hintmask_isValid( &hintMask ) )
40
FT_TRACE4(( "cf2_interpT2CharString:"
41
" invalid horizontal hint mask\n" ));
49
/* never add hints after the mask is computed */
50
if ( cf2_hintmask_isValid( &hintMask ) )
52
FT_TRACE4(( "cf2_interpT2CharString:"
53
" invalid vertical hint mask\n" ));
59
@@ -1141,15 +1147,16 @@
60
/* `cf2_hintmask_read' (which also traces the mask bytes) */
61
FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
63
- /* if there are arguments on the stack, there this is an */
64
- /* implied cf2_cmdVSTEMHM */
65
- if ( cf2_stack_count( opStack ) != 0 )
66
+ /* never add hints after the mask is computed */
67
+ if ( cf2_stack_count( opStack ) > 1 &&
68
+ cf2_hintmask_isValid( &hintMask ) )
70
- /* never add hints after the mask is computed */
71
- if ( cf2_hintmask_isValid( &hintMask ) )
72
- FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
73
+ FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
77
+ /* if there are arguments on the stack, there this is an */
78
+ /* implied cf2_cmdVSTEMHM */