Title: [185095] trunk
Revision
185095
Author
mmaxfi...@apple.com
Date
2015-06-01 19:10:05 -0700 (Mon, 01 Jun 2015)

Log Message

Out of bounds read in WebCore::ComplexTextController::adjustGlyphsAndAdvances
https://bugs.webkit.org/show_bug.cgi?id=145537
<rdar://problem/20959267>

Reviewed by Darin Adler.

Source/WebCore:

U16_IS_SURROGATE_LEAD(ch) assumes U16_IS_SURROGATE(ch). In this case, that isn't true.

Test: fast/text/crash-complex-text-surrogate.html

* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::adjustGlyphsAndAdvances):

LayoutTests:

* fast/text/crash-complex-text-surrogate.html: Added.
* platform/mac/fast/text/crash-complex-text-surrogate-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (185094 => 185095)


--- trunk/LayoutTests/ChangeLog	2015-06-02 01:53:45 UTC (rev 185094)
+++ trunk/LayoutTests/ChangeLog	2015-06-02 02:10:05 UTC (rev 185095)
@@ -1,3 +1,14 @@
+2015-06-01  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Out of bounds read in WebCore::ComplexTextController::adjustGlyphsAndAdvances
+        https://bugs.webkit.org/show_bug.cgi?id=145537
+        <rdar://problem/20959267>
+
+        Reviewed by Darin Adler.
+
+        * fast/text/crash-complex-text-surrogate.html: Added.
+        * platform/mac/fast/text/crash-complex-text-surrogate-expected.txt: Added.
+
 2015-05-30  Zalan Bujtas  <za...@apple.com>
 
         REGRESSION (179771): zooming on facebook images covers image

Added: trunk/LayoutTests/fast/text/crash-complex-text-surrogate.html (0 => 185095)


--- trunk/LayoutTests/fast/text/crash-complex-text-surrogate.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/crash-complex-text-surrogate.html	2015-06-02 02:10:05 UTC (rev 185095)
@@ -0,0 +1,88 @@
+<!DOCTYPE html>
+<html id="webtest0">
+<head id="webtest1">
+<script id="webtest2" type="text/_javascript_">
+
+function boom()
+{
+  var y = document.createTextNode('Y');
+  document.body.insertBefore(y, document.getElementById("v").nextSibling);
+}
+
+</script>
+</head>
+
+<body class="wf_class0" id="webtest3" _onload_="boom();" style="-moz-column-count: 2; width: 10ch; letter-spacing: 1px; font-family: monospace;">
+This test passes if you can open the file without a crash.
+<div class="wf_class0" style="background: lightblue; float: right; height: 14em; width: 1ch;" id="v"></div>a bcd<span id="webtest4">&#x202B;X</span>
+</body>
+<script>
+function webtest_fn_1() {
+try {
+delete document.scripts[3].toString();
+} catch(e) {
+  document.write("Errlog webtest_fn_1: " + e.name + ": " + e.message + "<br><acronym></acronym>");
+}
+}
+webtest_fn_1();
+</script>
+<script>
+function webtest_fn_2() {
+var s = "{,}\ua888{0}\P{P}\\7H\\8";
+var f = "gi";
+document.write("s is: " +s + "<br> f is: " + f + "<br>");
+var r = new RegExp(s, f);
+document.forms[0].outerHTML.search(r);
+r.compile(s, f);
+document.getElementById("webtest1").outerHTML.match(r);
+document.styleSheets[3].outerHTML.replace(r, "replacement");
+r.test(s);
+r.exec(s);
+}
+webtest_fn_2();
+</script>
+<script>
+function webtest_fn_3() {
+try {
+var head = document.getElementsByTagName("head")[0];
+var style = document.createElement("style");
+style.innerHTML="#wf_class0 { \n\
+-webkit-animation-name: name1; \n\
+-webkit-animation-duration: 1s; \n\
+-webkit-animation: none; \n\
+-webkit-animation-delay: now; \n\
+} \n\
+@-webkit-keyframes name1 { \n\
+  from { \n\
+    -webkit-mask-size: -4096%; \n\
+    background-image: -webkit-cross-fade(url(&#x0056;&#x00e8;&#x0055;&#x1e52;&#x02e3;&#x000f;&#xbe6d;&#x02c7;&#x006c;&#x22c4;&#x00b9;&#x02a1;&#x01f3;&#x00c1;&#x01dc;&#x0293;&#x001f;&#x0092;&#x0298;&#x07bb;&#xbfae;&#x0171;&#x0034;&#x024d;&#x010c;&#x016e;&#x0132;&#x01d6;&#x02d9;&#x00f1;&#x01ff;&#x02f5;&#x02b1;&#x39a6;&#x022e;&#x01c7;&#x024f;&#x0093;&#x002e;&#x00f5;&#x0221;&#xfac5;&#x0164;&#x2a35;&#x00ad;&#x02cd;&#x02dc;&#x00af;&#x0161;&#x0195;&#x018e;), url(text), 99%); \n\
+  } \n\
+  to { \n\
+    -webkit-mask-size: 32767in; \n\
+    background-image: none; \n\
+  } \n\
+} \n\
+";
+head.appendChild(style);
+} catch(e) {
+  document.write("Errlog webtest_fn_3: " + e.name + ": " + e.message + "<br><sub/>");
+}
+}
+webtest_fn_3();
+</script>
+<script>
+function webtest_fn_4() {
+try {
+var scroll_81 = document.createElement("bdo");
+scroll_81.setAttribute("id", "webtest8");
+document.querySelector("plaintext:first-of-type ~ *|:out-of-range").insertBefore(scroll_81, document.querySelector("plaintext:first-of-type ~ *|:out-of-range").childNodes[9]);
+scroll_81.setAttribute("style", "overflow: scroll");
+scroll_81.scrollLeft = 0;
+scroll_81.scrolltop = 0xffffffff;
+} catch(e) {
+  document.write("Errlog webtest_fn_4: " + e.name + ": " + e.message + "<br>");
+}
+}
+webtest_fn_4();
+</script>
+</html>

Added: trunk/LayoutTests/platform/mac/fast/text/crash-complex-text-surrogate-expected.txt (0 => 185095)


--- trunk/LayoutTests/platform/mac/fast/text/crash-complex-text-surrogate-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/text/crash-complex-text-surrogate-expected.txt	2015-06-02 02:10:05 UTC (rev 185095)
@@ -0,0 +1,60 @@
+CONSOLE MESSAGE: line 35: TypeError: undefined is not an object (evaluating 'document.forms[0].outerHTML')
+layer at (0,0) size 785x693
+  RenderView at (0,0) size 785x600
+layer at (0,0) size 785x693
+  RenderBlock {HTML} at (0,0) size 785x693
+    RenderBody {BODY} at (8,8) size 78x677
+      RenderText {#text} at (0,0) size 71x120
+        text run at (0,0) width 36: "This"
+        text run at (0,15) width 36: "test"
+        text run at (0,30) width 53: "passes"
+        text run at (0,45) width 53: "if you"
+        text run at (0,60) width 71: "can open"
+        text run at (0,75) width 71: "the file"
+        text run at (0,90) width 62: "without"
+        text run at (0,105) width 71: "a crash."
+      RenderBlock (floating) {DIV} at (70,120) size 8x182 [bgcolor=#ADD8E6]
+      RenderText {#text} at (0,120) size 9x15
+        text run at (0,120) width 9: "Y"
+      RenderText {#text} at (8,120) size 45x15
+        text run at (8,120) width 45: "a bcd"
+      RenderInline {SPAN} at (0,0) size 10x15
+        RenderText {#text} at (52,120) size 10x15
+          text run at (52,120) width 10: "\x{202B}X"
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,135) size 273x287
+        text run at (0,135) width 53: "Errlog"
+        text run at (0,302) width 115: "webtest_fn_1:"
+        text run at (0,317) width 89: "TypeError:"
+        text run at (0,332) width 80: "undefined"
+        text run at (0,347) width 53: "is not"
+        text run at (0,362) width 18: "an"
+        text run at (0,377) width 53: "object"
+        text run at (0,392) width 97: "(evaluating"
+        text run at (0,407) width 273: "'document.scripts[3].toString')"
+      RenderBR {BR} at (0,0) size 0x0
+      RenderInline {ACRONYM} at (0,0) size 0x0
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,422) size 115x45
+        text run at (0,422) width 45: "s is:"
+        text run at (0,437) width 27: "{,}"
+        text run at (0,452) width 115: "\x{A888}{0}P{P}\\7H\\8"
+      RenderBR {BR} at (0,0) size 0x0
+      RenderText {#text} at (0,467) size 71x15
+        text run at (0,467) width 71: "f is: gi"
+      RenderBR {BR} at (70,467) size 1x15
+      RenderText {#text} at (0,482) size 361x195
+        text run at (0,482) width 53: "Errlog"
+        text run at (0,497) width 115: "webtest_fn_4:"
+        text run at (0,512) width 89: "TypeError:"
+        text run at (0,527) width 62: "null is"
+        text run at (0,542) width 53: "not an"
+        text run at (0,557) width 53: "object"
+        text run at (0,572) width 97: "(evaluating"
+        text run at (0,587) width 361: "'document.querySelector(\"plaintext:first-"
+        text run at (0,602) width 62: "of-type"
+        text run at (0,617) width 9: "~"
+        text run at (0,632) width 62: "*|:out-"
+        text run at (0,647) width 27: "of-"
+        text run at (0,662) width 194: "range\").insertBefore')"
+      RenderBR {BR} at (0,0) size 0x0

Modified: trunk/Source/WebCore/ChangeLog (185094 => 185095)


--- trunk/Source/WebCore/ChangeLog	2015-06-02 01:53:45 UTC (rev 185094)
+++ trunk/Source/WebCore/ChangeLog	2015-06-02 02:10:05 UTC (rev 185095)
@@ -1,3 +1,18 @@
+2015-06-01  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Out of bounds read in WebCore::ComplexTextController::adjustGlyphsAndAdvances
+        https://bugs.webkit.org/show_bug.cgi?id=145537
+        <rdar://problem/20959267>
+
+        Reviewed by Darin Adler.
+
+        U16_IS_SURROGATE_LEAD(ch) assumes U16_IS_SURROGATE(ch). In this case, that isn't true.
+
+        Test: fast/text/crash-complex-text-surrogate.html
+
+        * platform/graphics/mac/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
+
 2015-05-30  Zalan Bujtas  <za...@apple.com>
 
         REGRESSION (179771): zooming on facebook images covers image

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp (185094 => 185095)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp	2015-06-02 01:53:45 UTC (rev 185094)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp	2015-06-02 02:10:05 UTC (rev 185095)
@@ -682,7 +682,7 @@
                 if (advance.width)
                     advance.width += m_font.letterSpacing();
 
-                bool lastCharacter = static_cast<unsigned>(characterIndex + 1) == m_run.length() || (U16_IS_SURROGATE_LEAD(ch) && static_cast<unsigned>(characterIndex + 2) == m_run.length() && U16_IS_SURROGATE_TRAIL(*(cp + characterIndex + 1)));
+                bool lastCharacter = static_cast<unsigned>(characterIndex + 1) == complexTextRun.stringLength() || (U16_IS_LEAD(ch) && static_cast<unsigned>(characterIndex + 2) == complexTextRun.stringLength() && U16_IS_TRAIL(*(cp + characterIndex + 1)));
 
                 bool forceLeadingExpansion = false; // On the left, regardless of m_run.ltr()
                 bool forceTrailingExpansion = false; // On the right, regardless of m_run.ltr()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to