Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp

Issue 2191253002: Prevent integer overflows in ANPlusB handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove longs Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp b/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp
index 08abeef92d575ce77255380052b964b3cc68ec5f..b2e0294c0a43ff94616f8fcdf84e6117901c4a1c 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp
@@ -69,6 +69,12 @@ TEST(CSSSelectorParserTest, ValidANPlusB)
{"+n/**/- 48", 1, -48},
{"-n + 81", -1, 81},
{"-N - 88", -1, -88},
+
+ {"3091970736n + 1", std::numeric_limits<int>::max(), 1},
+ {"-3091970736n + 1", std::numeric_limits<int>::min(), 1},
+ // B is calculated as +ve first, then negated.
+ {"N- 3091970736", 1, -std::numeric_limits<int>::max()},
+ {"N+ 3091970736", 1, std::numeric_limits<int>::max()},
};
for (auto testCase : testCases) {
@@ -79,8 +85,8 @@ TEST(CSSSelectorParserTest, ValidANPlusB)
CSSParserTokenRange range = scope.tokenRange();
bool passed = CSSSelectorParser::consumeANPlusB(range, ab);
EXPECT_TRUE(passed);
- EXPECT_EQ(ab.first, testCase.a);
- EXPECT_EQ(ab.second, testCase.b);
+ EXPECT_EQ(testCase.a, ab.first);
+ EXPECT_EQ(testCase.b, ab.second);
}
}
@@ -301,7 +307,7 @@ TEST(CSSSelectorParserTest, SerializedUniversal)
CSSParserTokenRange range = scope.tokenRange();
CSSSelectorList list = CSSSelectorParser::parseSelector(range, context, sheet);
EXPECT_TRUE(list.isValid());
- EXPECT_STREQ(testCase[1], list.selectorsText().ascii().data());
+ EXPECT_STREQ(list.selectorsText().ascii().data(), testCase[1]);
}
}

Powered by Google App Engine
This is Rietveld 408576698