diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-06-24 10:01:26 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-06-24 10:01:26 +0000 |
commit | 9aaa304277267acde7833431e19a90fce52c2c54 (patch) | |
tree | 6fb45f28e5432d993f0a98b5035a4d152124e964 | |
parent | 7ee335c95f102ae222f2118bc17d3039b48a3ea0 (diff) | |
parent | d216198488b966732583aedb192b017ff106a9ba (diff) |
Snap for 7488450 from d216198488b966732583aedb192b017ff106a9ba to s-keystone-qcom-release
Change-Id: I56b3cf5fadbd6912ebe88d3bddaa076fb2c5e275
-rw-r--r-- | libc/bionic/malloc_heapprofd.cpp | 10 | ||||
-rw-r--r-- | libc/dns/resolv/res_cache.c | 37 | ||||
-rw-r--r-- | tests/dl_test.cpp | 15 |
3 files changed, 22 insertions, 40 deletions
diff --git a/libc/bionic/malloc_heapprofd.cpp b/libc/bionic/malloc_heapprofd.cpp index 198bcbab7..741b45e98 100644 --- a/libc/bionic/malloc_heapprofd.cpp +++ b/libc/bionic/malloc_heapprofd.cpp @@ -325,12 +325,12 @@ void HeapprofdRememberHookConflict() { static void CommonInstallHooks(libc_globals* globals) { void* impl_handle = atomic_load(&gHeapprofdHandle); - bool reusing_handle = impl_handle != nullptr; - if (!reusing_handle) { + if (impl_handle == nullptr) { impl_handle = LoadSharedLibrary(kHeapprofdSharedLib, kHeapprofdPrefix, &globals->malloc_dispatch_table); if (impl_handle == nullptr) { return; } + atomic_store(&gHeapprofdHandle, impl_handle); } else if (!InitSharedLibrary(impl_handle, kHeapprofdSharedLib, kHeapprofdPrefix, &globals->malloc_dispatch_table)) { return; } @@ -341,11 +341,7 @@ static void CommonInstallHooks(libc_globals* globals) { // MaybeModifyGlobals locks at this point. atomic_store(&gPreviousDefaultDispatchTable, GetDefaultDispatchTable()); - if (FinishInstallHooks(globals, nullptr, kHeapprofdPrefix)) { - atomic_store(&gHeapprofdHandle, impl_handle); - } else if (!reusing_handle) { - dlclose(impl_handle); - } + FinishInstallHooks(globals, nullptr, kHeapprofdPrefix); } void HeapprofdInstallHooksAtInit(libc_globals* globals) { diff --git a/libc/dns/resolv/res_cache.c b/libc/dns/resolv/res_cache.c index c1c2059ef..f4c590f60 100644 --- a/libc/dns/resolv/res_cache.c +++ b/libc/dns/resolv/res_cache.c @@ -28,7 +28,6 @@ #include "resolv_cache.h" -#include <ctype.h> #include <resolv.h> #include <stdarg.h> #include <stdio.h> @@ -454,22 +453,6 @@ typedef struct { const uint8_t* cursor; } DnsPacket; -static int -memcasecmp( const unsigned char *s1, const unsigned char *s2, int len ) -{ - for ( int i = 0; i < len; i++ ) - { - int ch1 = *s1++; - int ch2 = *s2++; - int d = tolower(ch1) - tolower(ch2); - if (d != 0) - { - return d; - } - } - return 0; -} - static void _dnsPacket_init( DnsPacket* packet, const uint8_t* buff, int bufflen ) { @@ -782,7 +765,6 @@ _dnsPacket_hashBytes( DnsPacket* packet, int numBytes, unsigned hash ) while (numBytes > 0 && p < end) { hash = hash*FNV_MULT ^ *p++; - numBytes -= 1; } packet->cursor = p; return hash; @@ -796,12 +778,14 @@ _dnsPacket_hashQName( DnsPacket* packet, unsigned hash ) const uint8_t* end = packet->end; for (;;) { + int c; + if (p >= end) { /* should not happen */ XLOG("%s: INTERNAL_ERROR: read-overflow !!\n", __FUNCTION__); break; } - int c = *p++; + c = *p++; if (c == 0) break; @@ -815,12 +799,9 @@ _dnsPacket_hashQName( DnsPacket* packet, unsigned hash ) __FUNCTION__); break; } - while (c > 0) { - int ch = *p++; - ch = tolower(ch); - hash = hash * (FNV_MULT ^ ch); - c--; + hash = hash*FNV_MULT ^ *p++; + c -= 1; } } packet->cursor = p; @@ -907,12 +888,14 @@ _dnsPacket_isEqualDomainName( DnsPacket* pack1, DnsPacket* pack2 ) const uint8_t* end2 = pack2->end; for (;;) { + int c1, c2; + if (p1 >= end1 || p2 >= end2) { XLOG("%s: INTERNAL_ERROR: read-overflow !!\n", __FUNCTION__); break; } - int c1 = *p1++; - int c2 = *p2++; + c1 = *p1++; + c2 = *p2++; if (c1 != c2) break; @@ -930,7 +913,7 @@ _dnsPacket_isEqualDomainName( DnsPacket* pack1, DnsPacket* pack2 ) __FUNCTION__); break; } - if (memcasecmp(p1, p2, c1) != 0) + if (memcmp(p1, p2, c1) != 0) break; p1 += c1; p2 += c1; diff --git a/tests/dl_test.cpp b/tests/dl_test.cpp index 766f27a0b..47bf13374 100644 --- a/tests/dl_test.cpp +++ b/tests/dl_test.cpp @@ -264,8 +264,11 @@ static void create_ld_config_file(const char* config_file) { #endif #if defined(__BIONIC__) -static bool is_debuggable_build() { - return android::base::GetBoolProperty("ro.debuggable", false); +// This test can't rely on ro.debuggable, because it might have been forced on +// in a user build ("Force Debuggable"). In that configuration, ro.debuggable is +// true, but Bionic's LD_CONFIG_FILE testing support is still disabled. +static bool is_user_build() { + return android::base::GetProperty("ro.build.type", "user") == std::string("user"); } #endif @@ -282,7 +285,7 @@ static bool is_debuggable_build() { TEST(dl, exec_with_ld_config_file) { #if defined(__BIONIC__) SKIP_WITH_HWASAN << "libclang_rt.hwasan is not found with custom ld config"; - if (!is_debuggable_build()) { + if (is_user_build()) { GTEST_SKIP() << "LD_CONFIG_FILE is not supported on user build"; } std::string helper = GetTestlibRoot() + @@ -319,7 +322,7 @@ TEST(dl, exec_with_ld_config_file) { TEST(dl, exec_with_ld_config_file_with_ld_preload) { #if defined(__BIONIC__) SKIP_WITH_HWASAN << "libclang_rt.hwasan is not found with custom ld config"; - if (!is_debuggable_build()) { + if (is_user_build()) { GTEST_SKIP() << "LD_CONFIG_FILE is not supported on user build"; } std::string helper = GetTestlibRoot() + @@ -356,8 +359,8 @@ TEST(dl, disable_ld_config_file) { // This test is only for CTS. GTEST_SKIP() << "test is not supported with root uid"; } - if (is_debuggable_build()) { - GTEST_SKIP() << "test is not supported on debuggable build"; + if (!is_user_build()) { + GTEST_SKIP() << "test requires user build"; } std::string error_message = std::string("CANNOT LINK EXECUTABLE ") + |