Filter logic for ip leak misses ::ffff:0.0.0.0

The current logic filtering out "any" address is incomplete in the case
when any address in IPv4 converted in IPv6 form is not filtered out.

BUG=
R=juberti@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/44429004

Cr-Commit-Position: refs/heads/master@{#8545}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8545 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
guoweis@webrtc.org 2015-03-01 23:45:16 +00:00
parent 2f6ae0de5b
commit 59ae5ff310
2 changed files with 14 additions and 1 deletions

View File

@ -275,7 +275,7 @@ bool IPIsAny(const IPAddress& ip) {
case AF_INET:
return ip == IPAddress(INADDR_ANY);
case AF_INET6:
return ip == IPAddress(in6addr_any);
return ip == IPAddress(in6addr_any) || ip == IPAddress(kV4MappedPrefix);
case AF_UNSPEC:
return false;
}

View File

@ -552,6 +552,19 @@ TEST(IPAddressTest, TestIsLoopback) {
EXPECT_TRUE(IPIsLoopback(IPAddress(in6addr_loopback)));
}
// Verify that IPIsAny catches all cases of "any" address.
TEST(IPAddressTest, TestIsAny) {
IPAddress addr;
EXPECT_TRUE(IPFromString(kIPv6AnyAddrString, &addr));
EXPECT_TRUE(IPIsAny(addr));
EXPECT_TRUE(IPFromString(kIPv4AnyAddrString, &addr));
EXPECT_TRUE(IPIsAny(addr));
EXPECT_TRUE(IPIsAny(IPAddress(kIPv4MappedAnyAddr)));
}
TEST(IPAddressTest, TestNormalized) {
// Check normalizing a ::ffff:a.b.c.d address.
IPAddress addr;