Blame SOURCES/0019-MU-Fix-buffer-upcast-leading-to-misalignment.patch

6a14f3
From 7514e0f35f08666aa0cd5edc2859104c19b7b2a1 Mon Sep 17 00:00:00 2001
6a14f3
From: Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de>
6a14f3
Date: Thu, 13 Jan 2022 16:48:30 +0100
6a14f3
Subject: [PATCH 19/23] MU: Fix buffer upcast leading to misalignment
6a14f3
6a14f3
Signed-off-by: Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de>
6a14f3
---
6a14f3
 src/tss2-mu/tpm2b-types.c | 6 ++++--
6a14f3
 1 file changed, 4 insertions(+), 2 deletions(-)
6a14f3
6a14f3
diff --git a/src/tss2-mu/tpm2b-types.c b/src/tss2-mu/tpm2b-types.c
6a14f3
index 6aa2feb3..2e10f487 100644
6a14f3
--- a/src/tss2-mu/tpm2b-types.c
6a14f3
+++ b/src/tss2-mu/tpm2b-types.c
6a14f3
@@ -208,8 +208,10 @@ TSS2_RC Tss2_MU_##type##_Marshal(type const *src, uint8_t buffer[], \
6a14f3
         return rc; \
6a14f3
 \
6a14f3
     /* Update the size to the real value */ \
6a14f3
-    if (buffer) \
6a14f3
-        *(UINT16 *)ptr = HOST_TO_BE_16(buffer + local_offset - ptr - 2); \
6a14f3
+    if (buffer) { \
6a14f3
+        UINT16 t = HOST_TO_BE_16(buffer + local_offset - ptr - 2); \
6a14f3
+        memcpy(ptr, &t, sizeof(t)); \
6a14f3
+    } \
6a14f3
 \
6a14f3
     if (offset != NULL) { \
6a14f3
         *offset = local_offset; \
6a14f3
-- 
6a14f3
2.34.3
6a14f3