Attest: Fix unaligned access issue
Use memory primitives to copy data instead of
pointer casting and dereferencing when memory
address can be unaligned.
Change-Id: I71ed1a63a1a8c8699a1680c82b934094e8ab5db3
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
diff --git a/bl2/src/boot_record.c b/bl2/src/boot_record.c
index e24d2c4..21c1904 100644
--- a/bl2/src/boot_record.c
+++ b/bl2/src/boot_record.c
@@ -280,7 +280,8 @@
* returns with error: SHARED_MEMORY_OVERWRITE
*/
for (; offset < tlv_end; offset += tlv_entry.tlv_len) {
- tlv_entry = *((struct shared_data_tlv_entry *)offset);
+ /* Create local copy to avoid unaligned access */
+ memcpy(&tlv_entry, (const void *)offset, SHARED_DATA_ENTRY_HEADER_SIZE);
if (GET_MAJOR(tlv_entry.tlv_type) == major_type &&
GET_MINOR(tlv_entry.tlv_type) == minor_type) {
return SHARED_MEMORY_OVERWRITE;