Title: [140848] trunk
Revision
140848
Author
[email protected]
Date
2013-01-25 10:45:23 -0800 (Fri, 25 Jan 2013)

Log Message

Regression(r139836): Crash in WTF::equalIgnoringCase
https://bugs.webkit.org/show_bug.cgi?id=107703

Reviewed by Eric Seidel.

Source/WebCore:

Check |a| is a CSS_IDENT before considering it a string and
calling equalIgnoringCase on it. To avoid future mistakes like
this, add a function override for equalIgnoringCase that takes
CSSParserValue as a parameter and ASSERTs if that CSSParserValue
is not a CSS_STRING/CSS_IDENT.

Test: fast/gradients/parse-radial-gradient-crash.html

* css/CSSParser.cpp:
(WebCore):
(WebCore::equalIgnoringCase):
(WebCore::CSSParser::parseAnimationName):
(WebCore::CSSParser::parseAnimationProperty):
(WebCore::CSSParser::parseDashboardRegions):
(WebCore::parseDeprecatedGradientPoint):
(WebCore::CSSParser::parseDeprecatedGradient):
(WebCore::CSSParser::parseLinearGradient):
(WebCore::CSSParser::parseRadialGradient):

LayoutTests:

* fast/gradients/parse-radial-gradient-crash-expected.txt: Added.
* fast/gradients/parse-radial-gradient-crash.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (140847 => 140848)


--- trunk/LayoutTests/ChangeLog	2013-01-25 18:33:07 UTC (rev 140847)
+++ trunk/LayoutTests/ChangeLog	2013-01-25 18:45:23 UTC (rev 140848)
@@ -1,3 +1,13 @@
+2013-01-25  Abhishek Arya  <[email protected]>
+
+        Regression(r139836): Crash in WTF::equalIgnoringCase
+        https://bugs.webkit.org/show_bug.cgi?id=107703
+
+        Reviewed by Eric Seidel.
+
+        * fast/gradients/parse-radial-gradient-crash-expected.txt: Added.
+        * fast/gradients/parse-radial-gradient-crash.html: Added.
+
 2013-01-25  Sudarsana Nagineni  <[email protected]>
 
         Unreviewed EFL gardening.

Added: trunk/LayoutTests/fast/gradients/parse-radial-gradient-crash-expected.txt (0 => 140848)


--- trunk/LayoutTests/fast/gradients/parse-radial-gradient-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/gradients/parse-radial-gradient-crash-expected.txt	2013-01-25 18:45:23 UTC (rev 140848)
@@ -0,0 +1,2 @@
+Test passes if it does not crash.
+

Added: trunk/LayoutTests/fast/gradients/parse-radial-gradient-crash.html (0 => 140848)


--- trunk/LayoutTests/fast/gradients/parse-radial-gradient-crash.html	                        (rev 0)
+++ trunk/LayoutTests/fast/gradients/parse-radial-gradient-crash.html	2013-01-25 18:45:23 UTC (rev 140848)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+Test passes if it does not crash.
+<h1 style='background-image: repeating-radial-gradient(137px 113px, rgb(90,  '></h1>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+</script>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/gradients/parse-radial-gradient-crash.html
___________________________________________________________________

Added: svn:executable

Modified: trunk/Source/WebCore/ChangeLog (140847 => 140848)


--- trunk/Source/WebCore/ChangeLog	2013-01-25 18:33:07 UTC (rev 140847)
+++ trunk/Source/WebCore/ChangeLog	2013-01-25 18:45:23 UTC (rev 140848)
@@ -1,3 +1,29 @@
+2013-01-25  Abhishek Arya  <[email protected]>
+
+        Regression(r139836): Crash in WTF::equalIgnoringCase
+        https://bugs.webkit.org/show_bug.cgi?id=107703
+
+        Reviewed by Eric Seidel.
+
+        Check |a| is a CSS_IDENT before considering it a string and
+        calling equalIgnoringCase on it. To avoid future mistakes like
+        this, add a function override for equalIgnoringCase that takes
+        CSSParserValue as a parameter and ASSERTs if that CSSParserValue
+        is not a CSS_STRING/CSS_IDENT.       
+
+        Test: fast/gradients/parse-radial-gradient-crash.html
+
+        * css/CSSParser.cpp:
+        (WebCore):
+        (WebCore::equalIgnoringCase):
+        (WebCore::CSSParser::parseAnimationName):
+        (WebCore::CSSParser::parseAnimationProperty):
+        (WebCore::CSSParser::parseDashboardRegions):
+        (WebCore::parseDeprecatedGradientPoint):
+        (WebCore::CSSParser::parseDeprecatedGradient):
+        (WebCore::CSSParser::parseLinearGradient):
+        (WebCore::CSSParser::parseRadialGradient):
+
 2013-01-25  Chang Shu  <[email protected]>
 
         Build broken when svg is disabled.

Modified: trunk/Source/WebCore/css/CSSParser.cpp (140847 => 140848)


--- trunk/Source/WebCore/css/CSSParser.cpp	2013-01-25 18:33:07 UTC (rev 140847)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2013-01-25 18:45:23 UTC (rev 140848)
@@ -176,6 +176,13 @@
     return a.is8Bit() ? WTF::equalIgnoringCase(b, a.characters8(), length) : WTF::equalIgnoringCase(b, a.characters16(), length);
 }
 
+template <unsigned N>
+static bool equalIgnoringCase(CSSParserValue* value, const char (&b)[N])
+{
+    ASSERT(value->unit == CSSPrimitiveValue::CSS_IDENT || value->unit == CSSPrimitiveValue::CSS_STRING);
+    return equalIgnoringCase(value->string, b);
+}
+
 static bool hasPrefix(const char* string, unsigned length, const char* prefix)
 {
     for (unsigned i = 0; i < length; ++i) {
@@ -4293,7 +4300,7 @@
 {
     CSSParserValue* value = m_valueList->current();
     if (value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPrimitiveValue::CSS_IDENT) {
-        if (value->id == CSSValueNone || (value->unit == CSSPrimitiveValue::CSS_STRING && equalIgnoringCase(value->string, "none"))) {
+        if (value->id == CSSValueNone || (value->unit == CSSPrimitiveValue::CSS_STRING && equalIgnoringCase(value, "none"))) {
             return cssValuePool().createIdentifierValue(CSSValueNone);
         } else {
             return createPrimitiveStringValue(value);
@@ -4318,9 +4325,9 @@
     int result = cssPropertyID(value->string);
     if (result)
         return cssValuePool().createIdentifierValue(result);
-    if (equalIgnoringCase(value->string, "all"))
+    if (equalIgnoringCase(value, "all"))
         return cssValuePool().createIdentifierValue(CSSValueAll);
-    if (equalIgnoringCase(value->string, "none")) {
+    if (equalIgnoringCase(value, "none")) {
         allowAnimationProperty = false;
         return cssValuePool().createIdentifierValue(CSSValueNone);
     }
@@ -4693,9 +4700,9 @@
             break;
         }
 
-        if (equalIgnoringCase(arg->string, "circle"))
+        if (equalIgnoringCase(arg, "circle"))
             region->m_isCircle = true;
-        else if (equalIgnoringCase(arg->string, "rectangle"))
+        else if (equalIgnoringCase(arg, "rectangle"))
             region->m_isRectangle = true;
         else {
             valid = false;
@@ -6907,13 +6914,13 @@
 {
     RefPtr<CSSPrimitiveValue> result;
     if (a->unit == CSSPrimitiveValue::CSS_IDENT) {
-        if ((equalIgnoringCase(a->string, "left") && horizontal)
-            || (equalIgnoringCase(a->string, "top") && !horizontal))
+        if ((equalIgnoringCase(a, "left") && horizontal)
+            || (equalIgnoringCase(a, "top") && !horizontal))
             result = cssValuePool().createValue(0., CSSPrimitiveValue::CSS_PERCENTAGE);
-        else if ((equalIgnoringCase(a->string, "right") && horizontal)
-                 || (equalIgnoringCase(a->string, "bottom") && !horizontal))
+        else if ((equalIgnoringCase(a, "right") && horizontal)
+                 || (equalIgnoringCase(a, "bottom") && !horizontal))
             result = cssValuePool().createValue(100., CSSPrimitiveValue::CSS_PERCENTAGE);
-        else if (equalIgnoringCase(a->string, "center"))
+        else if (equalIgnoringCase(a, "center"))
             result = cssValuePool().createValue(50., CSSPrimitiveValue::CSS_PERCENTAGE);
     } else if (a->unit == CSSPrimitiveValue::CSS_NUMBER || a->unit == CSSPrimitiveValue::CSS_PERCENTAGE)
         result = cssValuePool().createValue(a->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(a->unit));
@@ -6996,9 +7003,9 @@
     CSSParserValue* a = args->current();
     if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT)
         return false;
-    if (equalIgnoringCase(a->string, "linear"))
+    if (equalIgnoringCase(a, "linear"))
         gradientType = CSSDeprecatedLinearGradient;
-    else if (equalIgnoringCase(a->string, "radial"))
+    else if (equalIgnoringCase(a, "radial"))
         gradientType = CSSDeprecatedRadialGradient;
     else
         return false;
@@ -7352,7 +7359,7 @@
 
         args->next();
         expectComma = true;
-    } else if (a->unit == CSSPrimitiveValue::CSS_IDENT && equalIgnoringCase(a->string, "to")) {
+    } else if (a->unit == CSSPrimitiveValue::CSS_IDENT && equalIgnoringCase(a, "to")) {
         // to [ [left | right] || [top | bottom] ]
         a = args->next();
         if (!a)
@@ -7499,7 +7506,7 @@
     // at <position>
     RefPtr<CSSValue> centerX;
     RefPtr<CSSValue> centerY;
-    if (equalIgnoringCase(a->string, "at")) {
+    if (a->unit == CSSPrimitiveValue::CSS_IDENT && equalIgnoringCase(a, "at")) {
         a = args->next();
         if (!a)
             return false;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to