Loading DnsResolver.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -31,10 +31,12 @@ bool resolv_init(const ResolverNetdCallbacks* callbacks) { resolv_set_log_severity(android::base::WARNING); uint64_t buildVersionSdk = android::base::GetUintProperty<uint64_t>("ro.build.version.sdk", 0); uint64_t buildVersionPreviewSdk = android::base::GetUintProperty<uint64_t>("ro.build.version.preview_sdk", 0); uint64_t firstApiLevel = android::base::GetUintProperty<uint64_t>("ro.product.first_api_level", 0); using android::net::gApiLevel; gApiLevel = std::max(buildVersionSdk, firstApiLevel); gApiLevel = std::max(buildVersionSdk + !!buildVersionPreviewSdk, firstApiLevel); using android::net::gResNetdCallbacks; gResNetdCallbacks.check_calling_permission = callbacks->check_calling_permission; gResNetdCallbacks.get_network_context = callbacks->get_network_context; Loading tests/dns_responder/dns_responder.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -171,7 +171,7 @@ char* DNSName::write(char* buffer, const char* buffer_end) const { for (size_t pos = 0; pos < name.size();) { size_t dot_pos = name.find('.', pos); if (dot_pos == std::string::npos) { // Sanity check, should never happen unless parseField is broken. // Soundness check, should never happen unless parseField is broken. LOG(ERROR) << "logic error: all names are expected to end with a '.'"; return nullptr; } Loading tests/resolv_integration_test.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -469,7 +469,7 @@ TEST_F(ResolverTest, GetHostByName_localhost) { constexpr char name_ip6_dot[] = "ip6-localhost."; constexpr char name_ip6_fqdn[] = "ip6-localhost.example.com."; // Add a dummy nameserver which shouldn't receive any queries // Add a no-op nameserver which shouldn't receive any queries test::DNSResponder dns; StartDns(dns, {}); ASSERT_TRUE(mDnsClient.SetResolversForNetwork()); Loading Loading @@ -518,7 +518,7 @@ TEST_F(ResolverTest, GetHostByName_localhost) { } TEST_F(ResolverTest, GetHostByName_numeric) { // Add a dummy nameserver which shouldn't receive any queries // Add a no-op nameserver which shouldn't receive any queries test::DNSResponder dns; StartDns(dns, {}); ASSERT_TRUE(mDnsClient.SetResolversForNetwork()); Loading Loading @@ -699,7 +699,7 @@ TEST_F(ResolverTest, GetAddrInfoV4) { } TEST_F(ResolverTest, GetAddrInfo_localhost) { // Add a dummy nameserver which shouldn't receive any queries // Add a no-op nameserver which shouldn't receive any queries test::DNSResponder dns; StartDns(dns, {}); ASSERT_TRUE(mDnsClient.SetResolversForNetwork()); Loading Loading @@ -2048,8 +2048,8 @@ int getAsyncResponse(int fd, int* rcode, uint8_t* buf, int bufLen) { if (revents & POLLIN) { int n = resNetworkResult(fd, rcode, buf, bufLen); // Verify that resNetworkResult() closed the fd char dummy; EXPECT_EQ(-1, read(fd, &dummy, sizeof dummy)); char unused; EXPECT_EQ(-1, read(fd, &unused, sizeof unused)); EXPECT_EQ(EBADF, errno); return n; } Loading Loading @@ -5269,7 +5269,7 @@ class ResolverMultinetworkTest : public ResolverTest { private: // Use a different netId because this class inherits from the class ResolverTest which // always creates TEST_NETID in setup. It's incremented when CreateScopedNetwork() is called. // Note: Don't create more than 20 networks in the class since 51 is used for the dummy network. // Note: Don't create more than 20 networks in the class since 51 is used for the mock network. unsigned mNextNetId = 31; }; Loading Loading
DnsResolver.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -31,10 +31,12 @@ bool resolv_init(const ResolverNetdCallbacks* callbacks) { resolv_set_log_severity(android::base::WARNING); uint64_t buildVersionSdk = android::base::GetUintProperty<uint64_t>("ro.build.version.sdk", 0); uint64_t buildVersionPreviewSdk = android::base::GetUintProperty<uint64_t>("ro.build.version.preview_sdk", 0); uint64_t firstApiLevel = android::base::GetUintProperty<uint64_t>("ro.product.first_api_level", 0); using android::net::gApiLevel; gApiLevel = std::max(buildVersionSdk, firstApiLevel); gApiLevel = std::max(buildVersionSdk + !!buildVersionPreviewSdk, firstApiLevel); using android::net::gResNetdCallbacks; gResNetdCallbacks.check_calling_permission = callbacks->check_calling_permission; gResNetdCallbacks.get_network_context = callbacks->get_network_context; Loading
tests/dns_responder/dns_responder.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -171,7 +171,7 @@ char* DNSName::write(char* buffer, const char* buffer_end) const { for (size_t pos = 0; pos < name.size();) { size_t dot_pos = name.find('.', pos); if (dot_pos == std::string::npos) { // Sanity check, should never happen unless parseField is broken. // Soundness check, should never happen unless parseField is broken. LOG(ERROR) << "logic error: all names are expected to end with a '.'"; return nullptr; } Loading
tests/resolv_integration_test.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -469,7 +469,7 @@ TEST_F(ResolverTest, GetHostByName_localhost) { constexpr char name_ip6_dot[] = "ip6-localhost."; constexpr char name_ip6_fqdn[] = "ip6-localhost.example.com."; // Add a dummy nameserver which shouldn't receive any queries // Add a no-op nameserver which shouldn't receive any queries test::DNSResponder dns; StartDns(dns, {}); ASSERT_TRUE(mDnsClient.SetResolversForNetwork()); Loading Loading @@ -518,7 +518,7 @@ TEST_F(ResolverTest, GetHostByName_localhost) { } TEST_F(ResolverTest, GetHostByName_numeric) { // Add a dummy nameserver which shouldn't receive any queries // Add a no-op nameserver which shouldn't receive any queries test::DNSResponder dns; StartDns(dns, {}); ASSERT_TRUE(mDnsClient.SetResolversForNetwork()); Loading Loading @@ -699,7 +699,7 @@ TEST_F(ResolverTest, GetAddrInfoV4) { } TEST_F(ResolverTest, GetAddrInfo_localhost) { // Add a dummy nameserver which shouldn't receive any queries // Add a no-op nameserver which shouldn't receive any queries test::DNSResponder dns; StartDns(dns, {}); ASSERT_TRUE(mDnsClient.SetResolversForNetwork()); Loading Loading @@ -2048,8 +2048,8 @@ int getAsyncResponse(int fd, int* rcode, uint8_t* buf, int bufLen) { if (revents & POLLIN) { int n = resNetworkResult(fd, rcode, buf, bufLen); // Verify that resNetworkResult() closed the fd char dummy; EXPECT_EQ(-1, read(fd, &dummy, sizeof dummy)); char unused; EXPECT_EQ(-1, read(fd, &unused, sizeof unused)); EXPECT_EQ(EBADF, errno); return n; } Loading Loading @@ -5269,7 +5269,7 @@ class ResolverMultinetworkTest : public ResolverTest { private: // Use a different netId because this class inherits from the class ResolverTest which // always creates TEST_NETID in setup. It's incremented when CreateScopedNetwork() is called. // Note: Don't create more than 20 networks in the class since 51 is used for the dummy network. // Note: Don't create more than 20 networks in the class since 51 is used for the mock network. unsigned mNextNetId = 31; }; Loading