Changeset 90901 in webkit
- Timestamp:
- Jul 13, 2011, 4:33:53 AM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r90900 r90901 1 2011-07-13 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Regression: OOB read in svg text run 4 https://bugs.webkit.org/show_bug.cgi?id=63627 5 6 Reviewed by Zoltan Herczeg. 7 8 A TextRun is constructed for a portion of a string [a,b] whose original length is c (0 < a < b < c). 9 The TextRun charactersLength variable stores the length of the remaining text from (b..c) in order 10 to support ligatures in SVG Fonts. Example: <text>ffl</text>. When measuring the advance from char 0 11 to char 1 the whole 'ffl' text must be passed to the SVG glyph selection code, as the SVG Font may 12 define a single glyph for the characters 'ffl' thus leading to a single character long text 13 pointing to the ffl ligature, not three individual 'f' / 'f' / 'l' characters anymore. 14 15 constructTextRun(..const UChar*, int length, ..) did not correctly calculate the maximum length (b..c). 16 The passed in UChar buffer starts at eg. textRenderer->characters() + start(), and following condition 17 holds true for 'length': start() + length <= textRenderer->textLength() (which denotes the maximum length 18 of the textRenderer->characters() buffer). We have to keep track of the start() offset, so that we 19 can calculate the charactersLength for the TextRun correctly: textRenderer->textLength() - start(). 20 21 There are also other cases like RenderCombinedText and/or the presence of hyphens that were incorrectly 22 tracked. Only InlineTextBox had to be fixed, the other callsites in eg. RenderBlockLineLayout already 23 computed the maximum length correctly - I assured this by valgrind runs on all SVG Font tests. 24 25 * rendering/InlineTextBox.cpp: 26 (WebCore::InlineTextBox::paint): 27 (WebCore::InlineTextBox::paintSelection): 28 (WebCore::InlineTextBox::constructTextRun): Add maximumLength parameter to constructTextRun. 29 * rendering/InlineTextBox.h: Ditto. 30 1 31 2011-07-12 Antti Koivisto <antti@apple.com> 2 32 -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r90791 r90901 642 642 643 643 int length = m_len; 644 int maximumLength; 644 645 const UChar* characters; 645 if (!combinedText) 646 if (!combinedText) { 646 647 characters = textRenderer()->text()->characters() + m_start; 647 else 648 maximumLength = textRenderer()->textLength() - m_start; 649 } else { 648 650 combinedText->charactersToRender(m_start, characters, length); 651 maximumLength = length; 652 } 649 653 650 654 BufferForAppendingHyphen charactersWithHyphen; 651 TextRun textRun = constructTextRun(styleToUse, font, characters, length, hasHyphen() ? &charactersWithHyphen : 0);655 TextRun textRun = constructTextRun(styleToUse, font, characters, length, maximumLength, hasHyphen() ? &charactersWithHyphen : 0); 652 656 if (hasHyphen()) 653 657 length = textRun.length(); … … 814 818 BufferForAppendingHyphen charactersWithHyphen; 815 819 bool respectHyphen = ePos == length && hasHyphen(); 816 TextRun textRun = constructTextRun(style, font, characters, length, respectHyphen ? &charactersWithHyphen : 0);820 TextRun textRun = constructTextRun(style, font, characters, length, textRenderer()->textLength() - length, respectHyphen ? &charactersWithHyphen : 0); 817 821 if (respectHyphen) 818 822 ePos = textRun.length(); … … 1299 1303 ASSERT(textRenderer->characters()); 1300 1304 1301 return constructTextRun(style, font, textRenderer->characters() + start(), len(), charactersWithHyphen);1302 } 1303 1304 TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, const UChar* characters, int length, BufferForAppendingHyphen* charactersWithHyphen) const1305 return constructTextRun(style, font, textRenderer->characters() + start(), len(), textRenderer->textLength() - start(), charactersWithHyphen); 1306 } 1307 1308 TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, const UChar* characters, int length, int maximumLength, BufferForAppendingHyphen* charactersWithHyphen) const 1305 1309 { 1306 1310 ASSERT(style); … … 1309 1313 ASSERT(textRenderer); 1310 1314 1311 if (charactersWithHyphen) 1315 if (charactersWithHyphen) { 1312 1316 adjustCharactersAndLengthForHyphen(*charactersWithHyphen, style, characters, length); 1317 maximumLength = length; 1318 } 1319 1320 ASSERT(maximumLength >= length); 1313 1321 1314 1322 TextRun run(characters, length, textRenderer->allowTabs(), textPos(), expansion(), expansionBehavior(), direction(), m_dirOverride || style->rtlOrdering() == VisualOrder); … … 1317 1325 1318 1326 // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring. 1319 run.setCharactersLength(textRenderer->textLength()); 1327 run.setCharactersLength(maximumLength); 1328 ASSERT(run.charactersLength() >= run.length()); 1320 1329 return run; 1321 1330 } -
trunk/Source/WebCore/rendering/InlineTextBox.h
r90600 r90901 101 101 102 102 TextRun constructTextRun(RenderStyle*, const Font&, BufferForAppendingHyphen* = 0) const; 103 TextRun constructTextRun(RenderStyle*, const Font&, const UChar*, int length, BufferForAppendingHyphen* = 0) const;103 TextRun constructTextRun(RenderStyle*, const Font&, const UChar*, int length, int maximumLength, BufferForAppendingHyphen* = 0) const; 104 104 105 105 public:
Note:
See TracChangeset
for help on using the changeset viewer.