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

Unified Diff: webrtc/base/win32_unittest.cc

Issue 2867653002: Fixing invalid IPv6 address parsing stack underflow on Windows. (Closed)
Patch Set: Fixing issue caught by new test. Created 3 years, 7 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
« no previous file with comments | « webrtc/base/win32.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/win32_unittest.cc
diff --git a/webrtc/base/win32_unittest.cc b/webrtc/base/win32_unittest.cc
index 15b2614111ca7eeacc6914dd339f0e3f8fa0073f..96e0bd292ab4b7b9c5b306b087127464ae02d1c3 100644
--- a/webrtc/base/win32_unittest.cc
+++ b/webrtc/base/win32_unittest.cc
@@ -92,4 +92,31 @@ TEST_F(Win32Test, IPv6AddressCompression) {
EXPECT_EQ("1234:5678:abcd:1234:5678:abcd:1234:5678", ipv6.ToString());
}
+// Test that invalid IPv6 addresses are recognized and false is returned.
+TEST_F(Win32Test, InvalidIPv6AddressParsing) {
+ IPAddress ipv6;
+
+ // More than 1 run of "::"s.
+ EXPECT_FALSE(IPFromString("1::2::3", &ipv6));
+
+ // More than 1 run of "::"s in a longer address.
+ // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=7592
+ EXPECT_FALSE(IPFromString("1::2::3::4::5::6::7::8", &ipv6));
+
+ // Three ':'s in a row.
+ EXPECT_FALSE(IPFromString("1:::2", &ipv6));
+
+ // Non-hex character.
+ EXPECT_FALSE(IPFromString("test::1", &ipv6));
+
+ // More than 4 hex digits per group.
+ EXPECT_FALSE(IPFromString("abcde::1", &ipv6));
+
+ // More than 8 groups.
+ EXPECT_FALSE(IPFromString("1:2:3:4:5:6:7:8:9", &ipv6));
+
+ // Less than 8 groups.
+ EXPECT_FALSE(IPFromString("1:2:3:4:5:6:7", &ipv6));
+}
+
} // namespace rtc
« no previous file with comments | « webrtc/base/win32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698