Changeset 206554 in webkit
- Timestamp:
- Sep 28, 2016, 2:53:53 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r206551 r206554 1 2016-09-28 Alex Christensen <achristensen@webkit.org> 2 3 URLParser should properly handle unexpected periods and overflows in IPv4 addresses 4 https://bugs.webkit.org/show_bug.cgi?id=162655 5 6 Reviewed by Geoffrey Garen. 7 8 Covered by new API tests. 9 10 * platform/URLParser.cpp: 11 (WebCore::URLParser::parseIPv4Number): 12 (WebCore::URLParser::parseIPv4Host): 13 * platform/URLParser.h: 14 1 15 2016-09-28 Wenson Hsieh <wenson_hsieh@apple.com> 2 16 -
trunk/Source/WebCore/platform/URLParser.cpp
r206549 r206554 1975 1975 Optional<uint32_t> URLParser::parseIPv4Number(CodePointIterator<CharacterType>& iterator, const CodePointIterator<CharacterType>& iteratorForSyntaxViolationPosition) 1976 1976 { 1977 // FIXME: Check for overflow.1978 1977 enum class State : uint8_t { 1979 1978 UnknownBase, … … 1984 1983 }; 1985 1984 State state = State::UnknownBase; 1986 uint32_t value = 0; 1985 Checked<uint32_t, RecordOverflow> value = 0; 1986 if (!iterator.atEnd() && *iterator == '.') 1987 return Nullopt; 1988 bool didSeeSyntaxViolation = false; 1987 1989 while (!iterator.atEnd()) { 1988 1990 if (*iterator == '.') { 1989 1991 ++iterator; 1990 return value; 1992 ASSERT(!value.hasOverflowed()); 1993 return value.unsafeGet(); 1991 1994 } 1992 1995 switch (state) { … … 2000 2003 break; 2001 2004 case State::OctalOrHex: 2002 syntaxViolation(iteratorForSyntaxViolationPosition);2005 didSeeSyntaxViolation = true; 2003 2006 if (*iterator == 'x' || *iterator == 'X') { 2004 2007 ++iterator; … … 2013 2016 value *= 10; 2014 2017 value += *iterator - '0'; 2018 if (UNLIKELY(value.hasOverflowed())) 2019 return Nullopt; 2015 2020 ++iterator; 2016 2021 break; 2017 2022 case State::Octal: 2018 ASSERT( m_didSeeSyntaxViolation);2023 ASSERT(didSeeSyntaxViolation); 2019 2024 if (*iterator < '0' || *iterator > '7') 2020 2025 return Nullopt; 2021 2026 value *= 8; 2022 2027 value += *iterator - '0'; 2028 if (UNLIKELY(value.hasOverflowed())) 2029 return Nullopt; 2023 2030 ++iterator; 2024 2031 break; 2025 2032 case State::Hex: 2026 ASSERT( m_didSeeSyntaxViolation);2033 ASSERT(didSeeSyntaxViolation); 2027 2034 if (!isASCIIHexDigit(*iterator)) 2028 2035 return Nullopt; 2029 2036 value *= 16; 2030 2037 value += toASCIIHexValue(*iterator); 2038 if (UNLIKELY(value.hasOverflowed())) 2039 return Nullopt; 2031 2040 ++iterator; 2032 2041 break; 2033 2042 } 2034 2043 } 2035 return value; 2044 if (didSeeSyntaxViolation) 2045 syntaxViolation(iteratorForSyntaxViolationPosition); 2046 ASSERT(!value.hasOverflowed()); 2047 return value.unsafeGet(); 2036 2048 } 2037 2049 … … 2070 2082 for (auto item : items) { 2071 2083 if (item > 255) 2072 return Nullopt;2084 syntaxViolation(hostBegin); 2073 2085 } 2074 2086 -
trunk/Tools/ChangeLog
r206553 r206554 1 2016-09-28 Alex Christensen <achristensen@webkit.org> 2 3 URLParser should properly handle unexpected periods and overflows in IPv4 addresses 4 https://bugs.webkit.org/show_bug.cgi?id=162655 5 6 Reviewed by Geoffrey Garen. 7 8 * TestWebKitAPI/Tests/WebCore/URLParser.cpp: 9 (TestWebKitAPI::TEST_F): 10 1 11 2016-09-28 Ryan Haddad <ryanhaddad@apple.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp
r206549 r206554 245 245 checkURL("notspecial:", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"}); 246 246 checkURL("http:/a", {"http", "", "", "a", 0, "/", "", "", "http://a/"}); 247 checkURL("http://256/", {"http", "", "", "256", 0, "/", "", "", "http://256/"}); 248 checkURL("http://256./", {"http", "", "", "256.", 0, "/", "", "", "http://256./"}); 249 checkURL("http://123.256/", {"http", "", "", "123.256", 0, "/", "", "", "http://123.256/"}); 247 checkURL("http://256../", {"http", "", "", "256..", 0, "/", "", "", "http://256../"}); 248 checkURL("http://256..", {"http", "", "", "256..", 0, "/", "", "", "http://256../"}); 249 checkURL("http://127..1/", {"http", "", "", "127..1", 0, "/", "", "", "http://127..1/"}); 250 checkURL("http://127.a.0.1/", {"http", "", "", "127.a.0.1", 0, "/", "", "", "http://127.a.0.1/"}); 251 checkURL("http://127.0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); 252 checkURL("http://12\t7.0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); 253 checkURL("http://127.\t0.0.1/", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"}); 254 checkURL("http://./", {"http", "", "", ".", 0, "/", "", "", "http://./"}); 255 checkURL("http://.", {"http", "", "", ".", 0, "/", "", "", "http://./"}); 250 256 checkURL("http://123\t.256/", {"http", "", "", "123.256", 0, "/", "", "", "http://123.256/"}); 251 257 checkURL("http://123.\t256/", {"http", "", "", "123.256", 0, "/", "", "", "http://123.256/"}); … … 678 684 {"file", "", "", "", 0, "/C:/", "", "foo/bar", "file:///C:/#foo/bar"}, 679 685 {"", "", "", "", 0, "", "", "", "//C|#foo/bar"}); 686 checkURLDifferences("http://0xFFFFFfFF/", 687 {"http", "", "", "255.255.255.255", 0, "/", "", "", "http://255.255.255.255/"}, 688 {"http", "", "", "0xffffffff", 0, "/", "", "", "http://0xffffffff/"}); 689 checkURLDifferences("http://0000000000000000037777777777/", 690 {"http", "", "", "255.255.255.255", 0, "/", "", "", "http://255.255.255.255/"}, 691 {"http", "", "", "0000000000000000037777777777", 0, "/", "", "", "http://0000000000000000037777777777/"}); 692 checkURLDifferences("http://4294967295/", 693 {"http", "", "", "255.255.255.255", 0, "/", "", "", "http://255.255.255.255/"}, 694 {"http", "", "", "4294967295", 0, "/", "", "", "http://4294967295/"}); 695 checkURLDifferences("http://256/", 696 {"http", "", "", "0.0.1.0", 0, "/", "", "", "http://0.0.1.0/"}, 697 {"http", "", "", "256", 0, "/", "", "", "http://256/"}); 698 checkURLDifferences("http://256./", 699 {"http", "", "", "0.0.1.0", 0, "/", "", "", "http://0.0.1.0/"}, 700 {"http", "", "", "256.", 0, "/", "", "", "http://256./"}); 701 checkURLDifferences("http://123.256/", 702 {"http", "", "", "123.0.1.0", 0, "/", "", "", "http://123.0.1.0/"}, 703 {"http", "", "", "123.256", 0, "/", "", "", "http://123.256/"}); 704 checkURLDifferences("http://127.%.0.1/", 705 {"", "", "", "", 0, "", "", "", "http://127.%.0.1/"}, 706 {"http", "", "", "127.%.0.1", 0, "/", "", "", "http://127.%.0.1/"}); 680 707 } 681 708
Note:
See TracChangeset
for help on using the changeset viewer.