systemd/SOURCES/0592-tpm2-use-memcpy_safe-instead-of-memcpy.patch

26 lines
1.2 KiB
Diff

From 7f1c570cc09a1bd03bf4d253997f40414643e9b1 Mon Sep 17 00:00:00 2001
From: Dan Streetman <ddstreet@ieee.org>
Date: Mon, 21 Aug 2023 18:10:56 -0400
Subject: [PATCH] tpm2: use memcpy_safe() instead of memcpy()
(cherry picked from commit 65fd657e0a13c0fdd4221cf6f22d51462a0bbc10)
Related: RHEL-16182
---
src/shared/tpm2-util.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/shared/tpm2-util.h b/src/shared/tpm2-util.h
index 6c836180c6..4f6f795fbb 100644
--- a/src/shared/tpm2-util.h
+++ b/src/shared/tpm2-util.h
@@ -199,7 +199,7 @@ int tpm2_tpm2b_public_to_fingerprint(const TPM2B_PUBLIC *public, void **ret_fing
struct_type UNIQ_T(STRUCT, uniq) = { .size_field = UNIQ_T(SIZE, uniq), }; \
assert(sizeof(UNIQ_T(STRUCT, uniq).buffer_field) >= (size_t) UNIQ_T(SIZE, uniq)); \
if (UNIQ_T(BUF, uniq)) \
- memcpy(UNIQ_T(STRUCT, uniq).buffer_field, UNIQ_T(BUF, uniq), UNIQ_T(SIZE, uniq)); \
+ memcpy_safe(UNIQ_T(STRUCT, uniq).buffer_field, UNIQ_T(BUF, uniq), UNIQ_T(SIZE, uniq)); \
UNIQ_T(STRUCT, uniq); \
})