Title: [206650] trunk
Revision
206650
Author
[email protected]
Date
2016-09-30 11:50:49 -0700 (Fri, 30 Sep 2016)

Log Message

Fix off-by-one error in URLParser::parseIPv4Host
https://bugs.webkit.org/show_bug.cgi?id=162789

Reviewed by Tim Horton.

Source/WebCore:

The spec says "If any but the last item in numbers is greater than 255, return failure."
This means check up to size - 1, not size - 2.

Covered by a new API test.

* platform/URLParser.cpp:
(WebCore::URLParser::parseIPv4Host):

Tools:

* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206649 => 206650)


--- trunk/Source/WebCore/ChangeLog	2016-09-30 18:48:28 UTC (rev 206649)
+++ trunk/Source/WebCore/ChangeLog	2016-09-30 18:50:49 UTC (rev 206650)
@@ -1,5 +1,20 @@
 2016-09-30  Alex Christensen  <[email protected]>
 
+        Fix off-by-one error in URLParser::parseIPv4Host
+        https://bugs.webkit.org/show_bug.cgi?id=162789
+
+        Reviewed by Tim Horton.
+
+        The spec says "If any but the last item in numbers is greater than 255, return failure."
+        This means check up to size - 1, not size - 2.
+
+        Covered by a new API test.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parseIPv4Host):
+
+2016-09-30  Alex Christensen  <[email protected]>
+
         URLParser: parsing a URL with an empty host and a colon should fail
         https://bugs.webkit.org/show_bug.cgi?id=162795
 

Modified: trunk/Source/WebCore/platform/URLParser.cpp (206649 => 206650)


--- trunk/Source/WebCore/platform/URLParser.cpp	2016-09-30 18:48:28 UTC (rev 206649)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2016-09-30 18:50:49 UTC (rev 206650)
@@ -2206,8 +2206,8 @@
     }
     if (!iterator.atEnd() || !items.size() || items.size() > 4)
         return Nullopt;
-    if (items.size() > 2) {
-        for (size_t i = 0; i < items.size() - 2; i++) {
+    if (items.size() > 1) {
+        for (size_t i = 0; i < items.size() - 1; i++) {
             if (items[i] > 255)
                 return Nullopt;
         }

Modified: trunk/Tools/ChangeLog (206649 => 206650)


--- trunk/Tools/ChangeLog	2016-09-30 18:48:28 UTC (rev 206649)
+++ trunk/Tools/ChangeLog	2016-09-30 18:50:49 UTC (rev 206650)
@@ -1,5 +1,15 @@
 2016-09-30  Alex Christensen  <[email protected]>
 
+        Fix off-by-one error in URLParser::parseIPv4Host
+        https://bugs.webkit.org/show_bug.cgi?id=162789
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
+2016-09-30  Alex Christensen  <[email protected]>
+
         URLParser: parsing a URL with an empty host and a colon should fail
         https://bugs.webkit.org/show_bug.cgi?id=162795
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (206649 => 206650)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-30 18:48:28 UTC (rev 206649)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-30 18:50:49 UTC (rev 206650)
@@ -292,6 +292,9 @@
     checkURL("http://127.0.0.1", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
     checkURL("http://127.0.0.1.", {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
     checkURL("http://127.0.0.1./", {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
+    checkURL("http://0x100.0/", {"http", "", "", "0x100.0", 0, "/", "", "", "http://0x100.0/"});
+    checkURL("http://0.0.0x100.0/", {"http", "", "", "0.0.0x100.0", 0, "/", "", "", "http://0.0.0x100.0/"});
+    checkURL("http://0.0.0.0x100/", {"http", "", "", "0.0.0.0x100", 0, "/", "", "", "http://0.0.0.0x100/"});
     checkURL("http://host:123?", {"http", "", "", "host", 123, "/", "", "", "http://host:123/?"});
     checkURL("http://host:123?query", {"http", "", "", "host", 123, "/", "query", "", "http://host:123/?query"});
     checkURL("http://host:123#", {"http", "", "", "host", 123, "/", "", "", "http://host:123/#"});
@@ -792,7 +795,6 @@
     checkRelativeURLDifferences("http://f:010/c", "http://example.org/foo/bar",
         {"http", "", "", "f", 10, "/c", "", "", "http://f:10/c"},
         {"http", "", "", "f", 10, "/c", "", "", "http://f:010/c"});
-    checkURL("http://0.0.0.0x100/", {"http", "", "", "0.0.0.0x100", 0, "/", "", "", "http://0.0.0.0x100/"});
 }
 
 TEST_F(URLParserTest, DefaultPort)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to