Fix unaligned load of 4 bytes for typeid

Use memcpy() to move the typeid to an aligned address.
This commit is contained in:
Rodrigo Arias 2024-07-29 13:17:37 +02:00
parent 61d57901b1
commit d98ca97624
2 changed files with 5 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) /* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "nanos6_priv.h" #include "nanos6_priv.h"
@ -521,7 +521,8 @@ pre_type(struct emu *emu)
} }
const uint8_t *data = &emu->ev->payload->jumbo.data[0]; const uint8_t *data = &emu->ev->payload->jumbo.data[0];
uint32_t typeid = *(uint32_t *) data; uint32_t typeid;
memcpy(&typeid, data, 4); /* May be unaligned */
data += 4; data += 4;
const char *label = (const char *) data; const char *label = (const char *) data;

View File

@ -546,7 +546,8 @@ pre_type(struct emu *emu)
} }
const uint8_t *data = &emu->ev->payload->jumbo.data[0]; const uint8_t *data = &emu->ev->payload->jumbo.data[0];
uint32_t typeid = *(uint32_t *) data; uint32_t typeid;
memcpy(&typeid, data, 4); /* May be unaligned */
data += 4; data += 4;
const char *label = (const char *) data; const char *label = (const char *) data;