| Index: net/base/net_util.cc
|
| diff --git a/net/base/net_util.cc b/net/base/net_util.cc
|
| index b9cf59f1789a910bed6242794417f5592f0694f1..e88a09e1f06f4be0fa8850d163d840cbaaee577d 100644
|
| --- a/net/base/net_util.cc
|
| +++ b/net/base/net_util.cc
|
| @@ -68,79 +68,79 @@ namespace {
|
| // The general list of blocked ports. Will be blocked unless a specific
|
| // protocol overrides it. (Ex: ftp can use ports 20 and 21)
|
| static const int kRestrictedPorts[] = {
|
| - 1, // tcpmux
|
| - 7, // echo
|
| - 9, // discard
|
| - 11, // systat
|
| - 13, // daytime
|
| - 15, // netstat
|
| - 17, // qotd
|
| - 19, // chargen
|
| - 20, // ftp data
|
| - 21, // ftp access
|
| - 22, // ssh
|
| - 23, // telnet
|
| - 25, // smtp
|
| - 37, // time
|
| - 42, // name
|
| - 43, // nicname
|
| - 53, // domain
|
| - 77, // priv-rjs
|
| - 79, // finger
|
| - 87, // ttylink
|
| - 95, // supdup
|
| - 101, // hostriame
|
| - 102, // iso-tsap
|
| - 103, // gppitnp
|
| - 104, // acr-nema
|
| - 109, // pop2
|
| - 110, // pop3
|
| - 111, // sunrpc
|
| - 113, // auth
|
| - 115, // sftp
|
| - 117, // uucp-path
|
| - 119, // nntp
|
| - 123, // NTP
|
| - 135, // loc-srv /epmap
|
| - 139, // netbios
|
| - 143, // imap2
|
| - 179, // BGP
|
| - 389, // ldap
|
| - 465, // smtp+ssl
|
| - 512, // print / exec
|
| - 513, // login
|
| - 514, // shell
|
| - 515, // printer
|
| - 526, // tempo
|
| - 530, // courier
|
| - 531, // chat
|
| - 532, // netnews
|
| - 540, // uucp
|
| - 556, // remotefs
|
| - 563, // nntp+ssl
|
| - 587, // stmp?
|
| - 601, // ??
|
| - 636, // ldap+ssl
|
| - 993, // ldap+ssl
|
| - 995, // pop3+ssl
|
| - 2049, // nfs
|
| - 3659, // apple-sasl / PasswordServer
|
| - 4045, // lockd
|
| - 6000, // X11
|
| - 6665, // Alternate IRC [Apple addition]
|
| - 6666, // Alternate IRC [Apple addition]
|
| - 6667, // Standard IRC [Apple addition]
|
| - 6668, // Alternate IRC [Apple addition]
|
| - 6669, // Alternate IRC [Apple addition]
|
| - 0xFFFF, // Used to block all invalid port numbers (see
|
| - // third_party/WebKit/Source/platform/weborigin/KURL.cpp,
|
| - // KURL::port())
|
| + 1, // tcpmux
|
| + 7, // echo
|
| + 9, // discard
|
| + 11, // systat
|
| + 13, // daytime
|
| + 15, // netstat
|
| + 17, // qotd
|
| + 19, // chargen
|
| + 20, // ftp data
|
| + 21, // ftp access
|
| + 22, // ssh
|
| + 23, // telnet
|
| + 25, // smtp
|
| + 37, // time
|
| + 42, // name
|
| + 43, // nicname
|
| + 53, // domain
|
| + 77, // priv-rjs
|
| + 79, // finger
|
| + 87, // ttylink
|
| + 95, // supdup
|
| + 101, // hostriame
|
| + 102, // iso-tsap
|
| + 103, // gppitnp
|
| + 104, // acr-nema
|
| + 109, // pop2
|
| + 110, // pop3
|
| + 111, // sunrpc
|
| + 113, // auth
|
| + 115, // sftp
|
| + 117, // uucp-path
|
| + 119, // nntp
|
| + 123, // NTP
|
| + 135, // loc-srv /epmap
|
| + 139, // netbios
|
| + 143, // imap2
|
| + 179, // BGP
|
| + 389, // ldap
|
| + 465, // smtp+ssl
|
| + 512, // print / exec
|
| + 513, // login
|
| + 514, // shell
|
| + 515, // printer
|
| + 526, // tempo
|
| + 530, // courier
|
| + 531, // chat
|
| + 532, // netnews
|
| + 540, // uucp
|
| + 556, // remotefs
|
| + 563, // nntp+ssl
|
| + 587, // stmp?
|
| + 601, // ??
|
| + 636, // ldap+ssl
|
| + 993, // ldap+ssl
|
| + 995, // pop3+ssl
|
| + 2049, // nfs
|
| + 3659, // apple-sasl / PasswordServer
|
| + 4045, // lockd
|
| + 6000, // X11
|
| + 6665, // Alternate IRC [Apple addition]
|
| + 6666, // Alternate IRC [Apple addition]
|
| + 6667, // Standard IRC [Apple addition]
|
| + 6668, // Alternate IRC [Apple addition]
|
| + 6669, // Alternate IRC [Apple addition]
|
| + 0xFFFF, // Used to block all invalid port numbers (see
|
| + // third_party/WebKit/Source/platform/weborigin/KURL.cpp,
|
| + // KURL::port())
|
| };
|
|
|
| // FTP overrides the following restricted ports.
|
| static const int kAllowedFtpPorts[] = {
|
| - 21, // ftp data
|
| - 22, // ssh
|
| + 21, // ftp data
|
| + 22, // ssh
|
| };
|
|
|
| bool IPNumberPrefixCheck(const IPAddressNumber& ip_number,
|
| @@ -191,7 +191,7 @@ std::string GetSpecificHeader(const std::string& headers,
|
|
|
| std::string::const_iterator begin =
|
| std::search(headers.begin(), headers.end(), match.begin(), match.end(),
|
| - base::CaseInsensitiveCompareASCII<char>());
|
| + base::CaseInsensitiveCompareASCII<char>());
|
|
|
| if (begin == headers.end())
|
| return std::string();
|
| @@ -199,9 +199,9 @@ std::string GetSpecificHeader(const std::string& headers,
|
| begin += match.length();
|
|
|
| std::string ret;
|
| - base::TrimWhitespace(std::string(begin,
|
| - std::find(begin, headers.end(), '\n')),
|
| - base::TRIM_ALL, &ret);
|
| + base::TrimWhitespace(
|
| + std::string(begin, std::find(begin, headers.end(), '\n')), base::TRIM_ALL,
|
| + &ret);
|
| return ret;
|
| }
|
|
|
| @@ -231,8 +231,8 @@ std::string GetDirectoryListingHeader(const base::string16& title) {
|
| static const base::StringPiece header(
|
| NetModule::GetResource(IDR_DIR_HEADER_HTML));
|
| // This can be null in unit tests.
|
| - DLOG_IF(WARNING, header.empty()) <<
|
| - "Missing resource: directory listing header";
|
| + DLOG_IF(WARNING, header.empty())
|
| + << "Missing resource: directory listing header";
|
|
|
| std::string result;
|
| if (!header.empty())
|
| @@ -308,7 +308,7 @@ bool IsPortAllowedByFtp(int port) {
|
| int array_size = arraysize(kAllowedFtpPorts);
|
| for (int i = 0; i < array_size; i++) {
|
| if (kAllowedFtpPorts[i] == port) {
|
| - return true;
|
| + return true;
|
| }
|
| }
|
| // Port not explicitly allowed by FTP, so return the default restrictions.
|
| @@ -352,7 +352,8 @@ bool ParseHostAndPort(std::string::const_iterator host_and_port_begin,
|
| url::Component port_component;
|
|
|
| url::ParseAuthority(auth_begin, auth_component, &username_component,
|
| - &password_component, &hostname_component, &port_component);
|
| + &password_component, &hostname_component,
|
| + &port_component);
|
|
|
| // There shouldn't be a username/password.
|
| if (username_component.is_valid() || password_component.is_valid())
|
| @@ -381,8 +382,8 @@ bool ParseHostAndPort(std::string::const_iterator host_and_port_begin,
|
| if (hostname_component.len > 0 &&
|
| auth_begin[hostname_component.begin] == '[') {
|
| if (auth_begin[hostname_component.end() - 1] == ']' &&
|
| - url::IPv6AddressToNumber(
|
| - auth_begin, hostname_component, tmp_ipv6_addr)) {
|
| + url::IPv6AddressToNumber(auth_begin, hostname_component,
|
| + tmp_ipv6_addr)) {
|
| // Strip the brackets.
|
| hostname_component.begin++;
|
| hostname_component.len -= 2;
|
| @@ -401,8 +402,8 @@ bool ParseHostAndPort(std::string::const_iterator host_and_port_begin,
|
| bool ParseHostAndPort(const std::string& host_and_port,
|
| std::string* host,
|
| int* port) {
|
| - return ParseHostAndPort(
|
| - host_and_port.begin(), host_and_port.end(), host, port);
|
| + return ParseHostAndPort(host_and_port.begin(), host_and_port.end(), host,
|
| + port);
|
| }
|
|
|
| std::string GetHostAndPort(const GURL& url) {
|
| @@ -422,8 +423,8 @@ std::string GetHostAndOptionalPort(const GURL& url) {
|
|
|
| bool IsHostnameNonUnique(const std::string& hostname) {
|
| // CanonicalizeHost requires surrounding brackets to parse an IPv6 address.
|
| - const std::string host_or_ip = hostname.find(':') != std::string::npos ?
|
| - "[" + hostname + "]" : hostname;
|
| + const std::string host_or_ip =
|
| + hostname.find(':') != std::string::npos ? "[" + hostname + "]" : hostname;
|
| url::CanonHostInfo host_info;
|
| std::string canonical_name = CanonicalizeHost(host_or_ip, &host_info);
|
|
|
| @@ -436,9 +437,9 @@ bool IsHostnameNonUnique(const std::string& hostname) {
|
| // range.
|
| if (host_info.IsIPAddress()) {
|
| IPAddressNumber host_addr;
|
| - if (!ParseIPLiteralToNumber(hostname.substr(host_info.out_host.begin,
|
| - host_info.out_host.len),
|
| - &host_addr)) {
|
| + if (!ParseIPLiteralToNumber(
|
| + hostname.substr(host_info.out_host.begin, host_info.out_host.len),
|
| + &host_addr)) {
|
| return false;
|
| }
|
| switch (host_info.family) {
|
| @@ -476,24 +477,31 @@ bool IsHostnameNonUnique(const std::string& hostname) {
|
| // They're formatted here with the prefix as the last element. For example:
|
| // 10.0.0.0/8 becomes 10,0,0,0,8 and fec0::/10 becomes 0xfe,0xc0,0,0,0...,10.
|
| bool IsIPAddressReserved(const IPAddressNumber& host_addr) {
|
| - static const unsigned char kReservedIPv4[][5] = {
|
| - { 0,0,0,0,8 }, { 10,0,0,0,8 }, { 100,64,0,0,10 }, { 127,0,0,0,8 },
|
| - { 169,254,0,0,16 }, { 172,16,0,0,12 }, { 192,0,2,0,24 },
|
| - { 192,88,99,0,24 }, { 192,168,0,0,16 }, { 198,18,0,0,15 },
|
| - { 198,51,100,0,24 }, { 203,0,113,0,24 }, { 224,0,0,0,3 }
|
| - };
|
| + static const unsigned char kReservedIPv4[][5] = {{0, 0, 0, 0, 8},
|
| + {10, 0, 0, 0, 8},
|
| + {100, 64, 0, 0, 10},
|
| + {127, 0, 0, 0, 8},
|
| + {169, 254, 0, 0, 16},
|
| + {172, 16, 0, 0, 12},
|
| + {192, 0, 2, 0, 24},
|
| + {192, 88, 99, 0, 24},
|
| + {192, 168, 0, 0, 16},
|
| + {198, 18, 0, 0, 15},
|
| + {198, 51, 100, 0, 24},
|
| + {203, 0, 113, 0, 24},
|
| + {224, 0, 0, 0, 3}};
|
| static const unsigned char kReservedIPv6[][17] = {
|
| - { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8 },
|
| - { 0x40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
|
| - { 0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
|
| - { 0xc0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3 },
|
| - { 0xe0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4 },
|
| - { 0xf0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5 },
|
| - { 0xf8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6 },
|
| - { 0xfc,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7 },
|
| - { 0xfe,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9 },
|
| - { 0xfe,0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10 },
|
| - { 0xfe,0xc0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10 },
|
| + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8},
|
| + {0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
|
| + {0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
|
| + {0xc0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
|
| + {0xe0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
|
| + {0xf0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5},
|
| + {0xf8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6},
|
| + {0xfc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7},
|
| + {0xfe, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9},
|
| + {0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10},
|
| + {0xfe, 0xc0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10},
|
| };
|
| size_t array_size = 0;
|
| const unsigned char* array = NULL;
|
| @@ -511,7 +519,7 @@ bool IsIPAddressReserved(const IPAddressNumber& host_addr) {
|
| return false;
|
| size_t width = host_addr.size() + 1;
|
| for (size_t i = 0; i < array_size; ++i, array += width) {
|
| - if (IPNumberPrefixCheck(host_addr, array, array[width-1]))
|
| + if (IPNumberPrefixCheck(host_addr, array, array[width - 1]))
|
| return true;
|
| }
|
| return false;
|
| @@ -563,8 +571,7 @@ bool GetIPAddressFromSockAddr(const struct sockaddr* sock_addr,
|
| if (sock_addr->sa_family == AF_BTH) {
|
| if (sock_addr_len < static_cast<socklen_t>(sizeof(SOCKADDR_BTH)))
|
| return false;
|
| - const SOCKADDR_BTH* addr =
|
| - reinterpret_cast<const SOCKADDR_BTH*>(sock_addr);
|
| + const SOCKADDR_BTH* addr = reinterpret_cast<const SOCKADDR_BTH*>(sock_addr);
|
| *address = reinterpret_cast<const uint8*>(&addr->btAddr);
|
| *address_len = kBluetoothAddressSize;
|
| if (port)
|
| @@ -576,8 +583,7 @@ bool GetIPAddressFromSockAddr(const struct sockaddr* sock_addr,
|
| return false; // Unrecognized |sa_family|.
|
| }
|
|
|
| -std::string IPAddressToString(const uint8* address,
|
| - size_t address_len) {
|
| +std::string IPAddressToString(const uint8* address, size_t address_len) {
|
| std::string str;
|
| url::StdStringCanonOutput output(&str);
|
|
|
| @@ -609,8 +615,8 @@ std::string NetAddressToString(const struct sockaddr* sa,
|
| socklen_t sock_addr_len) {
|
| const uint8* address;
|
| size_t address_len;
|
| - if (!GetIPAddressFromSockAddr(sa, sock_addr_len, &address,
|
| - &address_len, NULL)) {
|
| + if (!GetIPAddressFromSockAddr(sa, sock_addr_len, &address, &address_len,
|
| + NULL)) {
|
| NOTREACHED();
|
| return std::string();
|
| }
|
| @@ -622,8 +628,8 @@ std::string NetAddressToStringWithPort(const struct sockaddr* sa,
|
| const uint8* address;
|
| size_t address_len;
|
| uint16 port;
|
| - if (!GetIPAddressFromSockAddr(sa, sock_addr_len, &address,
|
| - &address_len, &port)) {
|
| + if (!GetIPAddressFromSockAddr(sa, sock_addr_len, &address, &address_len,
|
| + &port)) {
|
| NOTREACHED();
|
| return std::string();
|
| }
|
| @@ -640,8 +646,7 @@ std::string IPAddressToStringWithPort(const IPAddressNumber& addr,
|
| }
|
|
|
| std::string IPAddressToPackedString(const IPAddressNumber& addr) {
|
| - return std::string(reinterpret_cast<const char *>(&addr.front()),
|
| - addr.size());
|
| + return std::string(reinterpret_cast<const char*>(&addr.front()), addr.size());
|
| }
|
|
|
| std::string GetHostName() {
|
| @@ -680,9 +685,8 @@ std::string GetHostOrSpecFromURL(const GURL& url) {
|
| bool CanStripTrailingSlash(const GURL& url) {
|
| // Omit the path only for standard, non-file URLs with nothing but "/" after
|
| // the hostname.
|
| - return url.IsStandard() && !url.SchemeIsFile() &&
|
| - !url.SchemeIsFileSystem() && !url.has_query() && !url.has_ref()
|
| - && url.path() == "/";
|
| + return url.IsStandard() && !url.SchemeIsFile() && !url.SchemeIsFileSystem() &&
|
| + !url.has_query() && !url.has_ref() && url.path() == "/";
|
| }
|
|
|
| GURL SimplifyUrlForRequest(const GURL& url) {
|
| @@ -754,8 +758,7 @@ bool HaveOnlyLoopbackAddresses() {
|
| }
|
|
|
| bool result = true;
|
| - for (struct ifaddrs* interface = interface_addr;
|
| - interface != NULL;
|
| + for (struct ifaddrs* interface = interface_addr; interface != NULL;
|
| interface = interface->ifa_next) {
|
| if (!(IFF_UP & interface->ifa_flags))
|
| continue;
|
| @@ -824,8 +827,8 @@ bool ParseURLHostnameToNumber(const std::string& hostname,
|
| // If it has a bracket, try parsing it as an IPv6 address.
|
| if (hostname[0] == '[') {
|
| ip_number->resize(16); // 128 bits.
|
| - return url::IPv6AddressToNumber(
|
| - hostname.data(), host_comp, &(*ip_number)[0]);
|
| + return url::IPv6AddressToNumber(hostname.data(), host_comp,
|
| + &(*ip_number)[0]);
|
| }
|
|
|
| // Otherwise, try IPv4.
|
| @@ -863,7 +866,7 @@ bool ParseIPLiteralToNumber(const std::string& ip_literal,
|
| namespace {
|
|
|
| const unsigned char kIPv4MappedPrefix[] =
|
| - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF };
|
| + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF};
|
| }
|
|
|
| IPAddressNumber ConvertIPv4NumberToIPv6Number(
|
| @@ -874,8 +877,7 @@ IPAddressNumber ConvertIPv4NumberToIPv6Number(
|
| // <80 bits of zeros> + <16 bits of ones> + <32-bit IPv4 address>.
|
| IPAddressNumber ipv6_number;
|
| ipv6_number.reserve(16);
|
| - ipv6_number.insert(ipv6_number.end(),
|
| - kIPv4MappedPrefix,
|
| + ipv6_number.insert(ipv6_number.end(), kIPv4MappedPrefix,
|
| kIPv4MappedPrefix + arraysize(kIPv4MappedPrefix));
|
| ipv6_number.insert(ipv6_number.end(), ipv4_number.begin(), ipv4_number.end());
|
| return ipv6_number;
|
| @@ -976,10 +978,8 @@ int GetPortFromSockaddr(const struct sockaddr* address, socklen_t address_len) {
|
| }
|
|
|
| bool IsLocalhost(const std::string& host) {
|
| - if (host == "localhost" ||
|
| - host == "localhost.localdomain" ||
|
| - host == "localhost6" ||
|
| - host == "localhost6.localdomain6")
|
| + if (host == "localhost" || host == "localhost.localdomain" ||
|
| + host == "localhost6" || host == "localhost6.localdomain6")
|
| return true;
|
|
|
| IPAddressNumber ip_number;
|
| @@ -1010,8 +1010,7 @@ bool IsLocalhost(const std::string& host) {
|
| }
|
|
|
| NetworkInterface::NetworkInterface()
|
| - : type(NetworkChangeNotifier::CONNECTION_UNKNOWN),
|
| - network_prefix(0) {
|
| + : type(NetworkChangeNotifier::CONNECTION_UNKNOWN), network_prefix(0) {
|
| }
|
|
|
| NetworkInterface::NetworkInterface(const std::string& name,
|
|
|