summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorDaniel Norman <danielnorman@google.com>2021-06-18 15:33:31 -0700
committerDaniel Norman <danielnorman@google.com>2021-06-18 15:33:32 -0700
commitd216198488b966732583aedb192b017ff106a9ba (patch)
tree6fb45f28e5432d993f0a98b5035a4d152124e964 /libc
parent5aeffd28678e6c0b1d6ff06de85dc7bf22b5e53d (diff)
parent0e5cfdbfafe857e39f876a8a23e7ae69474d75c2 (diff)
Merge SP1A.210616.001
Change-Id: Iaee20aa65555899f2491489489edf90f69364041
Diffstat (limited to 'libc')
-rw-r--r--libc/bionic/malloc_heapprofd.cpp10
-rw-r--r--libc/dns/resolv/res_cache.c37
2 files changed, 13 insertions, 34 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;