diff --git a/net/BUILD.gn b/net/BUILD.gn index de607701226d..206ac565e12a 100644 --- a/net/BUILD.gn +++ b/net/BUILD.gn @@ -1234,8 +1234,6 @@ component("net") { sources += [ "base/network_change_notifier_linux.cc", "base/network_change_notifier_linux.h", - "base/network_interfaces_linux.cc", - "base/platform_mime_util_linux.cc", "proxy_resolution/proxy_config_service_linux.cc", "proxy_resolution/proxy_config_service_linux.h", ] @@ -1710,7 +1708,6 @@ source_set("net_deps") { ":cronet_buildflags", ":isolation_info_proto", ":net_export_header", - ":net_resources", ":preload_decoder", "//base", @@ -1719,7 +1716,6 @@ source_set("net_deps") { "//third_party/protobuf:protobuf_lite", "//third_party/zlib", "//url:buildflags", - "//third_party/boringssl", ] @@ -2146,7 +2142,7 @@ static_library("test_support") { ] if (is_win) { sources += [ "test/spawned_test_server/local_test_server_win.cc" ] - } else if (is_posix) { + } else if (is_posix || is_fuchsia) { sources += [ "test/spawned_test_server/local_test_server_posix.cc" ] } } @@ -2216,7 +2212,10 @@ if (!is_ios && !is_android && !use_cobalt_customizations) { proto_library("cert_verify_comparison_tool_proto") { sources = [ "tools/cert_verify_tool/dumper.proto" ] - # visibility = [ ":cert_verify_comparison_tool" ] + +if (!use_cobalt_customizations) { + visibility = [ ":cert_verify_comparison_tool" ] +} } executable("cert_verify_comparison_tool") { @@ -5398,8 +5397,7 @@ if (!use_cobalt_customizations) { proto_library("backoff_entry_serializer_fuzzer_input") { proto_in_dir = "//" sources = [ "base/backoff_entry_serializer_fuzzer_input.proto" ] - - # link_deps = [ "//testing/libfuzzer/proto:json_proto" ] + link_deps = [ "//testing/libfuzzer/proto:json_proto" ] } fuzzer_test("net_backoff_entry_serializer_fuzzer") { @@ -6005,8 +6003,7 @@ if (!use_cobalt_customizations) { proto_library("reporting_policy_proto") { proto_in_dir = "//" sources = [ "reporting/reporting_policy.proto" ] - - # link_deps = [ "//testing/libfuzzer/proto:json_proto" ] + link_deps = [ "//testing/libfuzzer/proto:json_proto" ] } } diff --git a/net/METADATA b/net/METADATA index 41052cafd79a..147c39f4bd14 100644 --- a/net/METADATA +++ b/net/METADATA @@ -3,11 +3,19 @@ description: "Subtree at net." third_party { - url { - type: GIT - value: "https://chromium.googlesource.com/chromium/src" + identifier { + type: "ChromiumVersion" + value: "114.0.5735.358" # from https://chromereleases.googleblog.com/2024/03/long-term-support-channel-update-for_26.html + } + identifier { + type: "Git" + value: "https://chromium.googlesource.com/chromium/src.git" + version: "1759c6ae9316996b9f150c0ce9d0ca78a3d15c02" + } + identifier { + type: "UpstreamSubdir" + value: "net" } - version: "114.0.5735.331" last_upgrade_date { year: 2023 month: 9 diff --git a/net/base/io_buffer.cc b/net/base/io_buffer.cc index 948659290489..114b17901786 100644 --- a/net/base/io_buffer.cc +++ b/net/base/io_buffer.cc @@ -120,9 +120,9 @@ void GrowableIOBuffer::SetCapacity(int capacity) { free(real_data_.release()); real_data_.reset(); } else { - real_data_.reset( - static_cast(realloc(real_data_.release(), capacity))); + real_data_.reset(static_cast(realloc(real_data_.release(), capacity))); } + capacity_ = capacity; if (offset_ > capacity) set_offset(capacity); diff --git a/net/base/network_change_notifier_linux.cc b/net/base/network_change_notifier_linux.cc index 534e5505afe5..1c95268d3ae9 100644 --- a/net/base/network_change_notifier_linux.cc +++ b/net/base/network_change_notifier_linux.cc @@ -30,9 +30,15 @@ class NetworkChangeNotifierLinux::BlockingThreadObjects { // Plumbing for NetworkChangeNotifier::GetCurrentConnectionType. // Safe to call from any thread. NetworkChangeNotifier::ConnectionType GetCurrentConnectionType() { +/* Cobalt + return address_tracker_.GetCurrentConnectionType(); +Cobalt */ return NetworkChangeNotifier::ConnectionType::CONNECTION_UNKNOWN; } +/* Cobalt + internal::AddressTrackerLinux* address_tracker() { return &address_tracker_; } +Cobalt */ internal::AddressTrackerLinux* address_tracker() { return nullptr; } // Begin watching for netlink changes. @@ -44,20 +50,41 @@ class NetworkChangeNotifierLinux::BlockingThreadObjects { void OnIPAddressChanged(); void OnLinkChanged(); // Used to detect online/offline state and IP address changes. +/* Cobalt + internal::AddressTrackerLinux address_tracker_; +Cobalt */ NetworkChangeNotifier::ConnectionType last_type_ = NetworkChangeNotifier::CONNECTION_NONE; }; NetworkChangeNotifierLinux::BlockingThreadObjects::BlockingThreadObjects( const std::unordered_set& ignored_interfaces, - scoped_refptr blocking_thread_runner) {} + scoped_refptr blocking_thread_runner) +/* Cobalt + : address_tracker_( + base::BindRepeating(&NetworkChangeNotifierLinux:: + BlockingThreadObjects::OnIPAddressChanged, + base::Unretained(this)), + base::BindRepeating( + &NetworkChangeNotifierLinux::BlockingThreadObjects::OnLinkChanged, + base::Unretained(this)), + base::DoNothing(), + ignored_interfaces, + std::move(blocking_thread_runner)) {} +Cobalt */ {} void NetworkChangeNotifierLinux::BlockingThreadObjects::Init() { +/* Cobalt + address_tracker_.Init(); +Cobalt */ last_type_ = GetCurrentConnectionType(); } void NetworkChangeNotifierLinux::BlockingThreadObjects::InitForTesting( base::ScopedFD netlink_fd) { +/* Cobalt + address_tracker_.InitWithFdForTesting(std::move(netlink_fd)); // IN-TEST +Cobalt */ last_type_ = GetCurrentConnectionType(); } diff --git a/net/base/network_interfaces_linux.cc b/net/base/network_interfaces_linux.cc index 74c6212a3e2b..05fa1c7f9798 100644 --- a/net/base/network_interfaces_linux.cc +++ b/net/base/network_interfaces_linux.cc @@ -85,10 +85,46 @@ namespace internal { // or ethtool extensions. NetworkChangeNotifier::ConnectionType GetInterfaceConnectionType( const std::string& ifname) { +/* Cobalt + base::ScopedFD s = GetSocketForIoctl(); + if (!s.is_valid()) + return NetworkChangeNotifier::CONNECTION_UNKNOWN; + + // Test wireless extensions for CONNECTION_WIFI + struct iwreq pwrq = {}; + strncpy(pwrq.ifr_name, ifname.c_str(), IFNAMSIZ - 1); + if (ioctl(s.get(), SIOCGIWNAME, &pwrq) != -1) + return NetworkChangeNotifier::CONNECTION_WIFI; + +#if !BUILDFLAG(IS_ANDROID) + // Test ethtool for CONNECTION_ETHERNET + struct ethtool_cmd ecmd = {}; + ecmd.cmd = ETHTOOL_GSET; + struct ifreq ifr = {}; + ifr.ifr_data = &ecmd; + strncpy(ifr.ifr_name, ifname.c_str(), IFNAMSIZ - 1); + if (ioctl(s.get(), SIOCETHTOOL, &ifr) != -1) + return NetworkChangeNotifier::CONNECTION_ETHERNET; +#endif // !BUILDFLAG(IS_ANDROID) +Cobalt */ + return NetworkChangeNotifier::CONNECTION_UNKNOWN; } std::string GetInterfaceSSID(const std::string& ifname) { +/* Cobalt + base::ScopedFD ioctl_socket = GetSocketForIoctl(); + if (!ioctl_socket.is_valid()) + return std::string(); + struct iwreq wreq = {}; + strncpy(wreq.ifr_name, ifname.c_str(), IFNAMSIZ - 1); + + char ssid[IW_ESSID_MAX_SIZE + 1] = {0}; + wreq.u.essid.pointer = ssid; + wreq.u.essid.length = IW_ESSID_MAX_SIZE; + if (ioctl(ioctl_socket.get(), SIOCGIWESSID, &wreq) != -1) + return ssid; +Cobalt */ return std::string(); } @@ -98,6 +134,66 @@ bool GetNetworkListImpl( const std::unordered_set& online_links, const internal::AddressTrackerLinux::AddressMap& address_map, GetInterfaceNameFunction get_interface_name) { +/* Cobalt + std::map ifnames; + + for (const auto& it : address_map) { + // Ignore addresses whose links are not online. + if (online_links.find(it.second.ifa_index) == online_links.end()) + continue; + + sockaddr_storage sock_addr; + socklen_t sock_len = sizeof(sockaddr_storage); + + // Convert to sockaddr for next check. + if (!IPEndPoint(it.first, 0) + .ToSockAddr(reinterpret_cast(&sock_addr), &sock_len)) { + continue; + } + + // Skip unspecified addresses (i.e. made of zeroes) and loopback addresses + if (IsLoopbackOrUnspecifiedAddress(reinterpret_cast(&sock_addr))) + continue; + + int ip_attributes = IP_ADDRESS_ATTRIBUTE_NONE; + + if (it.second.ifa_family == AF_INET6) { + // Ignore addresses whose attributes are not actionable by + // the application layer. + if (!TryConvertNativeToNetIPAttributes(it.second.ifa_flags, + &ip_attributes)) + continue; + } + + // Find the name of this link. + std::map::const_iterator itname = + ifnames.find(it.second.ifa_index); + std::string ifname; + if (itname == ifnames.end()) { + char buffer[IFNAMSIZ] = {0}; + ifname.assign(get_interface_name(it.second.ifa_index, buffer)); + // Ignore addresses whose interface name can't be retrieved. + if (ifname.empty()) + continue; + ifnames[it.second.ifa_index] = ifname; + } else { + ifname = itname->second; + } + + // Based on the interface name and policy, determine whether we + // should ignore it. + if (ShouldIgnoreInterface(ifname, policy)) + continue; + + NetworkChangeNotifier::ConnectionType type = + GetInterfaceConnectionType(ifname); + + networks->push_back( + NetworkInterface(ifname, ifname, it.second.ifa_index, type, it.first, + it.second.ifa_prefixlen, ip_attributes)); + } +Cobalt */ + return true; } @@ -119,6 +215,12 @@ std::string GetWifiSSIDFromInterfaceListInternal( } base::ScopedFD GetSocketForIoctl() { +/* Cobalt + base::ScopedFD ioctl_socket(socket(AF_INET6, SOCK_DGRAM, 0)); + if (ioctl_socket.is_valid()) + return ioctl_socket; + return base::ScopedFD(socket(AF_INET, SOCK_DGRAM, 0)); +Cobalt */ return base::ScopedFD(); } @@ -152,7 +254,9 @@ bool GetNetworkList(NetworkInterfaceList* networks, int policy) { #endif // BUILDFLAG(IS_ANDROID) const AddressMapOwnerLinux* map_owner = nullptr; - // absl::optional temp_tracker; +/* Cobalt + absl::optional temp_tracker; +Cobalt */ #if BUILDFLAG(IS_LINUX) // If NetworkChangeNotifier already maintains a map owner in this process, use // it. @@ -161,11 +265,13 @@ bool GetNetworkList(NetworkInterfaceList* networks, int policy) { } #endif // BUILDFLAG(IS_LINUX) if (!map_owner) { +/* Cobalt // If there is no existing map_owner, create an AdressTrackerLinux and // initialize it. - // temp_tracker.emplace(); - // temp_tracker->Init(); - // map_owner = &temp_tracker.value(); + temp_tracker.emplace(); + temp_tracker->Init(); + map_owner = &temp_tracker.value(); +Cobalt */ } return internal::GetNetworkListImpl( diff --git a/net/base/platform_mime_util_linux.cc b/net/base/platform_mime_util_linux.cc index cbc83fae8dd5..4d124ba12a04 100644 --- a/net/base/platform_mime_util_linux.cc +++ b/net/base/platform_mime_util_linux.cc @@ -36,24 +36,26 @@ bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( const base::FilePath::StringType& ext, std::string* result) const { return false; - // base::FilePath dummy_path("foo." + ext); - // std::string out = base::nix::GetFileMimeType(dummy_path); +/* Cobalt + base::FilePath dummy_path("foo." + ext); + std::string out = base::nix::GetFileMimeType(dummy_path); - // // GetFileMimeType likes to return application/octet-stream - // // for everything it doesn't know - ignore that. - // if (out == "application/octet-stream" || out.empty()) - // return false; + // GetFileMimeType likes to return application/octet-stream + // for everything it doesn't know - ignore that. + if (out == "application/octet-stream" || out.empty()) + return false; - // // GetFileMimeType returns image/x-ico because that's what's in the XDG - // // mime database. That database is the merger of the Gnome and KDE mime - // // databases. Apparently someone working on KDE in 2001 decided .ico - // // resolves to image/x-ico, whereas the rest of the world uses image/x-icon. - // // FWIW, image/vnd.microsoft.icon is the official IANA assignment. - // if (out == "image/x-ico") - // out = "image/x-icon"; + // GetFileMimeType returns image/x-ico because that's what's in the XDG + // mime database. That database is the merger of the Gnome and KDE mime + // databases. Apparently someone working on KDE in 2001 decided .ico + // resolves to image/x-ico, whereas the rest of the world uses image/x-icon. + // FWIW, image/vnd.microsoft.icon is the official IANA assignment. + if (out == "image/x-ico") + out = "image/x-icon"; - // *result = out; - // return true; + *result = out; + return true; +Cobalt */ } #endif // BUILDFLAG(IS_ANDROID) diff --git a/net/cert/pki/ocsp.cc b/net/cert/pki/ocsp.cc index ea6f4ca1a83b..72044ebd0d62 100644 --- a/net/cert/pki/ocsp.cc +++ b/net/cert/pki/ocsp.cc @@ -765,20 +765,22 @@ OCSPRevocationStatus GetRevocationStatusForCert( if (!CheckCertIDMatchesCertificate(cert_id, cert, issuer_certificate)) continue; +/* Cobalt // The SingleResponse matches the certificate, but may be out of date. Out // of date responses are noted seperate from responses with mismatched // serial numbers. If an OCSP responder provides both an up to date // response and an expired response, the up to date response takes // precedence (PROVIDED > INVALID_DATE). - // if (!CheckRevocationDateValid(single_response.this_update, - // single_response.has_next_update - // ? &single_response.next_update - // : nullptr, - // verify_time_epoch_seconds, max_age_seconds)) { - // if (*response_details != OCSPVerifyResult::PROVIDED) - // *response_details = OCSPVerifyResult::INVALID_DATE; - // continue; - // } + if (!CheckRevocationDateValid(single_response.this_update, + single_response.has_next_update + ? &single_response.next_update + : nullptr, + verify_time_epoch_seconds, max_age_seconds)) { + if (*response_details != OCSPVerifyResult::PROVIDED) + *response_details = OCSPVerifyResult::INVALID_DATE; + continue; + } +Cobalt */ // In the case with multiple matching and up to date responses, keep only // the strictest status (REVOKED > UNKNOWN > GOOD). diff --git a/net/cookies/cookie_util.cc b/net/cookies/cookie_util.cc index fb7dcaf7719d..1b3c0adf45fd 100644 --- a/net/cookies/cookie_util.cc +++ b/net/cookies/cookie_util.cc @@ -326,6 +326,9 @@ bool GetCookieDomainWithString(const GURL& url, // a sequence of individual domain name labels"; a label can only be empty if // it is the last label in the name, but a name ending in `..` would have an // empty label in the penultimate position and is thus invalid. +/* Cobalt + if (url_host.ends_with("..")) { +Cobalt */ if (base::EndsWith(url_host, "..")) { return false; } diff --git a/net/disk_cache/blockfile/mapped_file_posix.cc b/net/disk_cache/blockfile/mapped_file_posix.cc index ddf66e905eb5..f31e9371a0a1 100644 --- a/net/disk_cache/blockfile/mapped_file_posix.cc +++ b/net/disk_cache/blockfile/mapped_file_posix.cc @@ -14,6 +14,30 @@ namespace disk_cache { void* MappedFile::Init(const base::FilePath& name, size_t size) { +/* Cobalt + DCHECK(!init_); + if (init_ || !File::Init(name)) + return nullptr; + + size_t temp_len = size ? size : 4096; + if (!size) + size = GetLength(); + + buffer_ = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, + platform_file(), 0); + init_ = true; + view_size_ = size; + DPLOG_IF(FATAL, buffer_ == MAP_FAILED) << "Failed to mmap " << name.value(); + if (buffer_ == MAP_FAILED) + buffer_ = nullptr; + + // Make sure we detect hardware failures reading the headers. + auto temp = std::make_unique(temp_len); + if (!Read(temp.get(), temp_len, 0)) + return nullptr; + + return buffer_; +Cobalt */ return nullptr; } @@ -21,6 +45,15 @@ void MappedFile::Flush() { } MappedFile::~MappedFile() { +/* Cobalt + if (!init_) + return; + + if (buffer_) { + int ret = munmap(buffer_, view_size_); + DCHECK_EQ(0, ret); + } +Cobalt */ } } // namespace disk_cache diff --git a/net/disk_cache/disk_cache_test_base.cc b/net/disk_cache/disk_cache_test_base.cc index a342907073b5..872cd4a622d6 100644 --- a/net/disk_cache/disk_cache_test_base.cc +++ b/net/disk_cache/disk_cache_test_base.cc @@ -50,8 +50,11 @@ bool DiskCacheTest::CopyTestCache(const std::string& name) { path = path.AppendASCII("cache_tests"); path = path.AppendASCII(name); +/* Cobalt if (!CleanupCacheDir()) return false; + return base::CopyDirectory(path, cache_path_, false); +Cobalt */ return false; } diff --git a/net/disk_cache/simple/simple_index.cc b/net/disk_cache/simple/simple_index.cc index b2700c1fd65f..48dc134c2862 100644 --- a/net/disk_cache/simple/simple_index.cc +++ b/net/disk_cache/simple/simple_index.cc @@ -620,6 +620,9 @@ void SimpleIndex::WriteToDisk(IndexWriteToDiskReason reason) { if (cleanup_tracker_) { // Make anyone synchronizing with our cleanup wait for the index to be // written back. +/* Cobalt + after_write = base::DoNothingWithBoundArgs(cleanup_tracker_); +Cobalt */ after_write = base::DoNothingWithBoundArgs(std::move(cleanup_tracker_)); } diff --git a/net/dns/BUILD.gn b/net/dns/BUILD.gn index 3b51206d4195..2021e463a9f3 100644 --- a/net/dns/BUILD.gn +++ b/net/dns/BUILD.gn @@ -527,7 +527,7 @@ if (!use_cobalt_customizations) { proto_library("host_cache_fuzzer_proto") { proto_in_dir = "//" sources = [ "host_cache_fuzzer.proto" ] - # deps = [ "//testing/libfuzzer/proto:json_proto" ] + deps = [ "//testing/libfuzzer/proto:json_proto" ] } fuzzer_test("net_dns_host_cache_fuzzer") { diff --git a/net/dns/context_host_resolver_unittest.cc b/net/dns/context_host_resolver_unittest.cc index c34b5999f3b1..928adabf6f1a 100644 --- a/net/dns/context_host_resolver_unittest.cc +++ b/net/dns/context_host_resolver_unittest.cc @@ -809,6 +809,9 @@ class NetworkAwareHostResolverProc : public HostResolverProc { handles::NetworkHandle network) override { // Presume failure *os_error = 1; +/* Cobalt + const auto* iter = kResults.find(network); +Cobalt */ const auto iter = kResults.find(network); if (iter == kResults.end()) return ERR_NETWORK_CHANGED; diff --git a/net/dns/dns_config_service_linux.cc b/net/dns/dns_config_service_linux.cc index d1d4361d28f4..37c725f60c86 100644 --- a/net/dns/dns_config_service_linux.cc +++ b/net/dns/dns_config_service_linux.cc @@ -340,6 +340,34 @@ class DnsConfigServiceLinux::Watcher : public DnsConfigService::Watcher { CheckOnCorrectSequence(); bool success = true; +/* Cobalt + if (!resolv_watcher_.Watch( + base::FilePath(kFilePathResolv), + base::FilePathWatcher::Type::kNonRecursive, + base::BindRepeating(&Watcher::OnResolvFilePathWatcherChange, + base::Unretained(this)))) { + LOG(ERROR) << "DNS config (resolv.conf) watch failed to start."; + success = false; + } + + if (!nsswitch_watcher_.Watch( + base::FilePath(kFilePathNsswitch), + base::FilePathWatcher::Type::kNonRecursive, + base::BindRepeating(&Watcher::OnNsswitchFilePathWatcherChange, + base::Unretained(this)))) { + LOG(ERROR) << "DNS nsswitch.conf watch failed to start."; + success = false; + } + + if (!hosts_watcher_.Watch( + base::FilePath(kFilePathHosts), + base::FilePathWatcher::Type::kNonRecursive, + base::BindRepeating(&Watcher::OnHostsFilePathWatcherChange, + base::Unretained(this)))) { + LOG(ERROR) << "DNS hosts watch failed to start."; + success = false; + } +Cobalt */ return success; } @@ -357,6 +385,12 @@ class DnsConfigServiceLinux::Watcher : public DnsConfigService::Watcher { void OnHostsFilePathWatcherChange(const base::FilePath& path, bool error) { OnHostsChanged(!error); } + +/* Cobalt + base::FilePathWatcher resolv_watcher_; + base::FilePathWatcher nsswitch_watcher_; + base::FilePathWatcher hosts_watcher_; +Cobalt */ }; // A SerialWorker that uses libresolv to initialize res_state and converts diff --git a/net/dns/dns_names_util_unittest.cc b/net/dns/dns_names_util_unittest.cc index 08f9356f8b43..c04b0335e037 100644 --- a/net/dns/dns_names_util_unittest.cc +++ b/net/dns/dns_names_util_unittest.cc @@ -773,10 +773,7 @@ TEST(DnsUtilTest, CanonicalizeNames) { EXPECT_EQ(UrlCanonicalizeNameIfAble("g{oo}gle.test"), "g%7Boo%7Dgle.test"); EXPECT_EQ(UrlCanonicalizeNameIfAble("G{OO}GLE.test"), "g%7Boo%7Dgle.test"); -// The MSVC compiler can't handle the below character, even in a comment. -#if !defined(COMPILER_MSVC) - // g�gle.test -#endif + // gügle.test EXPECT_EQ(UrlCanonicalizeNameIfAble("g\u00FCgle.test"), "xn--ggle-0ra.test"); EXPECT_EQ(UrlCanonicalizeNameIfAble("G\u00fcGLE.test"), "xn--ggle-0ra.test"); } diff --git a/net/dns/host_resolver_internal_result.cc b/net/dns/host_resolver_internal_result.cc index 12cd46f08cb2..bb3434156833 100644 --- a/net/dns/host_resolver_internal_result.cc +++ b/net/dns/host_resolver_internal_result.cc @@ -100,6 +100,9 @@ absl::optional QueryTypeFromValue(const base::Value& value) { const std::string* query_type_string = value.GetIfString(); if (!query_type_string) return absl::nullopt; +/* Cobalt + const auto* query_type_it = +Cobalt */ const auto query_type_it = base::ranges::find(kDnsQueryTypes, *query_type_string, &decltype(kDnsQueryTypes)::value_type::second); @@ -261,6 +264,9 @@ bool HostResolverInternalResult::ValidateValueBaseDict( const std::string* query_type_string = dict.FindString(kValueQueryTypeKey); if (!query_type_string) return false; +/* Cobalt + const auto* query_type_it = +Cobalt */ const auto query_type_it = base::ranges::find(kDnsQueryTypes, *query_type_string, &decltype(kDnsQueryTypes)::value_type::second); diff --git a/net/dns/mock_host_resolver.h b/net/dns/mock_host_resolver.h index aa86d7c4fd83..488036fbe87d 100644 --- a/net/dns/mock_host_resolver.h +++ b/net/dns/mock_host_resolver.h @@ -240,6 +240,9 @@ class MockHostResolverBase } private: +/* Cobalt + friend class RefCounted; +Cobalt */ friend class base::RefCounted; ~State(); @@ -680,6 +683,9 @@ class HangingHostResolver : public HostResolver { void IncrementNumCancellations() { ++num_cancellations_; } private: +/* Cobalt + friend class RefCounted; +Cobalt */ friend class base::RefCounted; ~State(); diff --git a/net/filter/gzip_header.cc b/net/filter/gzip_header.cc index a94a902935ba..69028c17b4bd 100644 --- a/net/filter/gzip_header.cc +++ b/net/filter/gzip_header.cc @@ -4,8 +4,9 @@ #include "net/filter/gzip_header.h" +#include + #include -#include #include "base/check_op.h" #include "third_party/zlib/zlib.h" diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc index 4e06c8e38afc..5353659ad912 100644 --- a/net/http/http_network_session.cc +++ b/net/http/http_network_session.cc @@ -335,6 +335,7 @@ base::Value HttpNetworkSession::QuicInfoToValue() const { static_cast( quic_params->initial_rtt_for_handshake.InMilliseconds())); #endif + return base::Value(std::move(dict)); } diff --git a/net/proxy_resolution/proxy_config_service_linux.cc b/net/proxy_resolution/proxy_config_service_linux.cc index 51b89520eeb5..463af719d53c 100644 --- a/net/proxy_resolution/proxy_config_service_linux.cc +++ b/net/proxy_resolution/proxy_config_service_linux.cc @@ -625,12 +625,14 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { PLOG(ERROR) << "inotify_init failed"; return false; } - // if (!base::SetNonBlocking(inotify_fd_)) { - // PLOG(ERROR) << "base::SetNonBlocking failed"; - // close(inotify_fd_); - // inotify_fd_ = -1; - // return false; - // } +/* Cobalt + if (!base::SetNonBlocking(inotify_fd_)) { + PLOG(ERROR) << "base::SetNonBlocking failed"; + close(inotify_fd_); + inotify_fd_ = -1; + return false; + } +Cobalt */ constexpr base::TaskTraits kTraits = {base::TaskPriority::USER_VISIBLE, base::MayBlock()}; @@ -646,7 +648,9 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { void ShutDown() override { if (inotify_fd_ >= 0) { ResetCachedSettings(); - // inotify_watcher_.reset(); +/* Cobalt + inotify_watcher_.reset(); +Cobalt */ close(inotify_fd_); inotify_fd_ = -1; } @@ -675,7 +679,12 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { return false; } notify_delegate_ = delegate; - +/* Cobalt + inotify_watcher_ = base::FileDescriptorWatcher::WatchReadable( + inotify_fd_, + base::BindRepeating(&SettingGetterImplKDE::OnChangeNotification, + base::Unretained(this))); +Cobalt */ // Simulate a change to avoid possibly losing updates before this point. OnChangeNotification(); return true; @@ -863,6 +872,9 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { bool at_least_one_kioslaverc_opened = false; for (const auto& kde_config_dir : kde_config_dirs_) { base::FilePath kioslaverc = kde_config_dir.Append("kioslaverc"); +/* Cobalt + base::ScopedFILE input(base::OpenFile(kioslaverc, "r")); +Cobalt */ base::ScopedFILE input(new starboard::ScopedFile(kioslaverc.value().c_str(), kSbFileOpenOnly | kSbFileRead)); if (!input.get()) continue; @@ -876,68 +888,70 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { bool line_too_long = false; char line[BUFFER_SIZE]; // fgets() will return NULL on EOF or error. - // while (fgets(line, sizeof(line), input.get())) { - // // fgets() guarantees the line will be properly terminated. - // size_t length = strlen(line); - // if (!length) - // continue; - // // This should be true even with CRLF endings. - // if (line[length - 1] != '\n') { - // line_too_long = true; - // continue; - // } - // if (line_too_long) { - // // The previous line had no line ending, but this one does. This is - // // the end of the line that was too long, so warn here and skip it. - // LOG(WARNING) << "skipped very long line in " << kioslaverc.value(); - // line_too_long = false; - // continue; - // } - // // Remove the LF at the end, and the CR if there is one. - // line[--length] = '\0'; - // if (length && line[length - 1] == '\r') - // line[--length] = '\0'; - // // Now parse the line. - // if (line[0] == '[') { - // // Switching sections. All we care about is whether this is - // // the (a?) proxy settings section, for both KDE3 and KDE4. - // in_proxy_settings = !strncmp(line, "[Proxy Settings]", 16); - // } else if (in_proxy_settings) { - // // A regular line, in the (a?) proxy settings section. - // char* split = strchr(line, '='); - // // Skip this line if it does not contain an = sign. - // if (!split) - // continue; - // // Split the line on the = and advance |split|. - // *(split++) = 0; - // std::string key = line; - // std::string value = split; - // base::TrimWhitespaceASCII(key, base::TRIM_ALL, &key); - // base::TrimWhitespaceASCII(value, base::TRIM_ALL, &value); - // // Skip this line if the key name is empty. - // if (key.empty()) - // continue; - // // Is the value name localized? - // if (key[key.length() - 1] == ']') { - // // Find the matching bracket. - // length = key.rfind('['); - // // Skip this line if the localization indicator is malformed. - // if (length == std::string::npos) - // continue; - // // Trim the localization indicator off. - // key.resize(length); - // // Remove any resulting trailing whitespace. - // base::TrimWhitespaceASCII(key, base::TRIM_TRAILING, &key); - // // Skip this line if the key name is now empty. - // if (key.empty()) - // continue; - // } - // // Now fill in the tables. - // AddKDESetting(key, value); - // } - // } - // if (ferror(input.get())) - // LOG(ERROR) << "error reading " << kioslaverc.value(); +/* Cobalt + while (fgets(line, sizeof(line), input.get())) { + // fgets() guarantees the line will be properly terminated. + size_t length = strlen(line); + if (!length) + continue; + // This should be true even with CRLF endings. + if (line[length - 1] != '\n') { + line_too_long = true; + continue; + } + if (line_too_long) { + // The previous line had no line ending, but this one does. This is + // the end of the line that was too long, so warn here and skip it. + LOG(WARNING) << "skipped very long line in " << kioslaverc.value(); + line_too_long = false; + continue; + } + // Remove the LF at the end, and the CR if there is one. + line[--length] = '\0'; + if (length && line[length - 1] == '\r') + line[--length] = '\0'; + // Now parse the line. + if (line[0] == '[') { + // Switching sections. All we care about is whether this is + // the (a?) proxy settings section, for both KDE3 and KDE4. + in_proxy_settings = !strncmp(line, "[Proxy Settings]", 16); + } else if (in_proxy_settings) { + // A regular line, in the (a?) proxy settings section. + char* split = strchr(line, '='); + // Skip this line if it does not contain an = sign. + if (!split) + continue; + // Split the line on the = and advance |split|. + *(split++) = 0; + std::string key = line; + std::string value = split; + base::TrimWhitespaceASCII(key, base::TRIM_ALL, &key); + base::TrimWhitespaceASCII(value, base::TRIM_ALL, &value); + // Skip this line if the key name is empty. + if (key.empty()) + continue; + // Is the value name localized? + if (key[key.length() - 1] == ']') { + // Find the matching bracket. + length = key.rfind('['); + // Skip this line if the localization indicator is malformed. + if (length == std::string::npos) + continue; + // Trim the localization indicator off. + key.resize(length); + // Remove any resulting trailing whitespace. + base::TrimWhitespaceASCII(key, base::TRIM_TRAILING, &key); + // Skip this line if the key name is now empty. + if (key.empty()) + continue; + } + // Now fill in the tables. + AddKDESetting(key, value); + } + } + if (ferror(input.get())) + LOG(ERROR) << "error reading " << kioslaverc.value(); +Cobalt */ } if (at_least_one_kioslaverc_opened) { ResolveModeEffects(); @@ -993,7 +1007,9 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { // large), but if it does we'd warn continuously since |inotify_fd_| // would be forever ready to read. Close it and stop watching instead. LOG(ERROR) << "inotify failure; no longer watching kioslaverc!"; - // inotify_watcher_.reset(); +/* Cobalt + inotify_watcher_.reset(); +Cobalt */ close(inotify_fd_); inotify_fd_ = -1; } @@ -1014,7 +1030,9 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter { std::vector > strings_map_type; int inotify_fd_ = -1; - // std::unique_ptr inotify_watcher_; +/* Cobalt + std::unique_ptr inotify_watcher_; +Cobalt */ raw_ptr notify_delegate_ = nullptr; std::unique_ptr debounce_timer_; std::vector kde_config_dirs_; diff --git a/net/quic/platform/impl/quic_test_flags_utils.cc b/net/quic/platform/impl/quic_test_flags_utils.cc index cefbcdf6352b..2b046d9ed64a 100644 --- a/net/quic/platform/impl/quic_test_flags_utils.cc +++ b/net/quic/platform/impl/quic_test_flags_utils.cc @@ -51,11 +51,9 @@ QuicFlagChecker::QuicFlagChecker() { QUIC_PROTOCOL_FLAG_CHECK(type, flag, external_value); #define CR_EXPAND_ARG(arg) #define GET_6TH_ARG(arg1, arg2, arg3, arg4, arg5, arg6, ...) arg6 -#define QUIC_PROTOCOL_FLAG(...) \ +#define QUIC_PROTOCOL_FLAG(...) \ CR_EXPAND_ARG(GET_6TH_ARG(__VA_ARGS__, DEFINE_QUIC_PROTOCOL_FLAG_TWO_VALUES, \ DEFINE_QUIC_PROTOCOL_FLAG_SINGLE_VALUE)(__VAR_ARGS__)) -// #define QUIC_PROTOCOL_FLAG(...) \ -// QUIC_PROTOCOL_FLAG_MACRO_CHOOSER(__VA_ARGS__)(__VA_ARGS__) #include "net/third_party/quiche/src/quiche/quic/core/quic_protocol_flags_list.h" #undef QUIC_PROTOCOL_FLAG #undef QUIC_PROTOCOL_FLAG_MACRO_CHOOSER diff --git a/net/quic/quic_chromium_client_session.cc b/net/quic/quic_chromium_client_session.cc index a1d37be5ba5a..4749b657d55b 100644 --- a/net/quic/quic_chromium_client_session.cc +++ b/net/quic/quic_chromium_client_session.cc @@ -3117,6 +3117,9 @@ QuicChromiumClientSession::CreateContextForMultiPortPath() { void QuicChromiumClientSession::MigrateToMultiPortPath( std::unique_ptr context) { +/* Cobalt + DCHECK_NE(nullptr, context); +Cobalt */ DCHECK_NE(nullptr, context.get()); auto* chrome_context = static_cast(context.get()); diff --git a/starboard/build/config/win/BUILD.gn b/starboard/build/config/win/BUILD.gn index 58ebf14bb234..52895dfd39b9 100644 --- a/starboard/build/config/win/BUILD.gn +++ b/starboard/build/config/win/BUILD.gn @@ -224,6 +224,9 @@ config("common") { # but it's a universally acceptable price for better performance. "/wd4820", + # warning C4828: character 'ü' in net/dns/dns_names_util_unittest.cc + "/wd4828", + # Disable static analyzer warning for std::min and std::max with # objects. # https://connect.microsoft.com/VisualStudio/feedback/details/783808/static-analyzer-warning-c28285-for-std-min-and-std-max