2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Assigning uint64_t from buffer might be misaligned in netmgr tests

Resolve possible 8-byte unaligned access when assigning the magic
value from the received buffer.
This commit is contained in:
Ondřej Surý
2021-01-29 13:16:38 +01:00
parent cb9df06f7d
commit a55bdb28f9
5 changed files with 10 additions and 10 deletions

View File

@@ -259,7 +259,7 @@ tcp_connect_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
atomic_fetch_add(&creads, 1);
magic = *(uint64_t *)tcp_buffer_storage;
memmove(&magic, tcp_buffer_storage, sizeof(magic));
assert_true(magic == stop_magic || magic == send_magic);
tcp_buffer_length -= sizeof(magic);
@@ -650,7 +650,7 @@ tcp_listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
if (tcp_buffer_length >= sizeof(magic)) {
isc_nm_pauseread(handle);
magic = *(uint64_t *)tcp_buffer_storage;
memmove(&magic, tcp_buffer_storage, sizeof(magic));
assert_true(magic == stop_magic || magic == send_magic);
tcp_buffer_length -= sizeof(magic);

View File

@@ -287,7 +287,7 @@ tcp_connect_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
while (tcp_buffer_length >= sizeof(magic)) {
atomic_fetch_add(&creads, 1);
magic = *(uint64_t *)tcp_buffer_storage;
memmove(&magic, tcp_buffer_storage, sizeof(magic));
assert_true(magic == stop_magic || magic == send_magic);
tcp_buffer_length -= sizeof(magic);
@@ -957,7 +957,7 @@ tcp_listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
tcp_buffer_length += region->length;
while (tcp_buffer_length >= sizeof(magic)) {
magic = *(uint64_t *)tcp_buffer_storage;
memmove(&magic, tcp_buffer_storage, sizeof(magic));
assert_true(magic == stop_magic || magic == send_magic);
tcp_buffer_length -= sizeof(magic);

View File

@@ -328,7 +328,7 @@ tcpdns_connect_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
atomic_fetch_add(&creads, 1);
magic = *(uint64_t *)region->base;
memmove(&magic, region->base, sizeof(magic));
assert_true(magic == stop_magic || magic == send_magic);
@@ -478,7 +478,7 @@ tcpdns_listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
assert_int_equal(region->length, sizeof(magic));
magic = *(uint64_t *)region->base;
memmove(&magic, region->base, sizeof(magic));
assert_true(magic == stop_magic || magic == send_magic);
if (magic == send_magic) {

View File

@@ -341,7 +341,7 @@ tlsdns_connect_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
atomic_fetch_add(&creads, 1);
magic = *(uint64_t *)region->base;
memmove(&magic, region->base, sizeof(magic));
assert_true(magic == stop_magic || magic == send_magic);
@@ -493,7 +493,7 @@ tlsdns_listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
assert_int_equal(region->length, sizeof(magic));
magic = *(uint64_t *)region->base;
memmove(&magic, region->base, sizeof(magic));
assert_true(magic == stop_magic || magic == send_magic);
if (magic == send_magic) {

View File

@@ -285,7 +285,7 @@ udp_listen_recv_cb(isc_nmhandle_t *handle, isc_result_t eresult,
assert_int_equal(region->length, sizeof(send_magic));
atomic_fetch_add(&sreads, 1);
magic = *(uint64_t *)region->base;
memmove(&magic, region->base, sizeof(magic));
assert_true(magic == stop_magic || magic == send_magic);
isc_nm_send(handle, region, udp_listen_send_cb, NULL);
@@ -552,7 +552,7 @@ udp_connect_recv_cb(isc_nmhandle_t *handle, isc_result_t eresult,
atomic_fetch_add(&creads, 1);
magic = *(uint64_t *)region->base;
memmove(&magic, region->base, sizeof(magic));
assert_true(magic == stop_magic || magic == send_magic);