MacOS UBSAN: another attempt

pull/772/head
Brad House 8 months ago
parent c40bdac234
commit 48dd3e5346
  1. 10
      src/lib/ares_sysconfig_mac.c

@ -273,12 +273,18 @@ static ares_status_t read_resolvers(dns_resolver_t **resolvers, int nresolvers,
int i;
for (i = 0; status == ARES_SUCCESS && i < nresolvers; i++) {
const dns_resolver_t *resolver_ptr;
dns_resolver_t resolver;
/* UBSAN doesn't like that this is unaligned, lets use memcpy to get the
* content. */
memcpy(&resolver, resolvers[i], sizeof(resolver));
* address. Equivalent to:
* resolver = resolvers[i]
*/
memcpy(&resolver_ptr, resolvers + i, sizeof(resolver_ptr));
/* UBSAN. If the pointer is misaligned, try to use memcpy to get the data
* into a new structure that is hopefully aligned properly */
memcpy(&resolver, resolver_ptr, sizeof(resolver));
status = read_resolver(&resolver, sysconfig);
}

Loading…
Cancel
Save