usp10: Range check glyph counts in GPOS_apply_ChainContextPos().

I.e., avoid accessing outside the "glyphs" array. If we're particularly
unlucky we may actually get a match against data outside the array.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Aric Stewart <aric@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2017-04-05 10:21:28 +02:00 committed by Alexandre Julliard
parent f6c0146499
commit 7dfe9b9c94
1 changed files with 12 additions and 0 deletions

View File

@ -2235,10 +2235,22 @@ static unsigned int GPOS_apply_ChainContextPos(const ScriptCache *script_cache,
TRACE(" subtype 3 (Coverage-based Chaining Context Glyph Positioning)\n");
backtrack_count = GET_BE_WORD(backtrack->BacktrackGlyphCount);
k = glyph_index + dirBacktrack * backtrack_count;
if (k < 0 || k >= glyph_count)
continue;
input = (const GPOS_ChainContextPosFormat3_2 *)&backtrack->Coverage[backtrack_count];
input_count = GET_BE_WORD(input->InputGlyphCount);
k = glyph_index + write_dir * (input_count - 1);
if (k < 0 || k >= glyph_count)
continue;
lookahead = (const GPOS_ChainContextPosFormat3_3 *)&input->Coverage[input_count];
lookahead_count = GET_BE_WORD(lookahead->LookaheadGlyphCount);
k = glyph_index + dirLookahead * (input_count + lookahead_count - 1);
if (k < 0 || k >= glyph_count)
continue;
positioning = (const GPOS_ChainContextPosFormat3_4 *)&lookahead->Coverage[lookahead_count];
for (k = 0; k < backtrack_count; ++k)