nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0277-commands-efi-tpm-Use-grub_strcpy-instead-of-grub_mem.patch

b35c50
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b35c50
From: Lu Ken <ken.lu@intel.com>
b35c50
Date: Wed, 13 Jul 2022 10:06:11 +0800
b35c50
Subject: [PATCH] commands/efi/tpm: Use grub_strcpy() instead of grub_memcpy()
b35c50
b35c50
The event description is a string, so using grub_strcpy() is cleaner than
b35c50
using grub_memcpy().
b35c50
b35c50
Signed-off-by: Lu Ken <ken.lu@intel.com>
b35c50
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
b35c50
(cherry picked from commit ef8679b645a63eb9eb191bb9539d7d25a9d6ff3b)
b35c50
---
b35c50
 grub-core/commands/efi/tpm.c | 4 ++--
b35c50
 1 file changed, 2 insertions(+), 2 deletions(-)
b35c50
b35c50
diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c
b35c50
index 7acf510499..bb59599721 100644
b35c50
--- a/grub-core/commands/efi/tpm.c
b35c50
+++ b/grub-core/commands/efi/tpm.c
b35c50
@@ -175,7 +175,7 @@ grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
b35c50
   event->PCRIndex = pcr;
b35c50
   event->EventType = EV_IPL;
b35c50
   event->EventSize = grub_strlen (description) + 1;
b35c50
-  grub_memcpy (event->Event, description, event->EventSize);
b35c50
+  grub_strcpy ((char *) event->Event, description);
b35c50
 
b35c50
   algorithm = TCG_ALG_SHA;
b35c50
   status = efi_call_7 (tpm->log_extend_event, tpm, (grub_addr_t) buf, (grub_uint64_t) size,
b35c50
@@ -212,7 +212,7 @@ grub_tpm2_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
b35c50
   event->Header.EventType = EV_IPL;
b35c50
   event->Size =
b35c50
     sizeof (*event) - sizeof (event->Event) + grub_strlen (description) + 1;
b35c50
-  grub_memcpy (event->Event, description, grub_strlen (description) + 1);
b35c50
+  grub_strcpy ((char *) event->Event, description);
b35c50
 
b35c50
   status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (grub_addr_t) buf,
b35c50
 		       (grub_uint64_t) size, event);