Blame SOURCES/0004-tpm2_eventlog-clean-up-some-magic-numbers.patch

c8bd4f
From 2781de8cb60d0e8efb72d57eb1178f2f6df9415c Mon Sep 17 00:00:00 2001
c8bd4f
From: Jerry Snitselaar <jsnitsel@redhat.com>
c8bd4f
Date: Tue, 2 Aug 2022 11:59:06 -0700
c8bd4f
Subject: [PATCH 4/9] tpm2_eventlog: clean up some magic numbers
c8bd4f
c8bd4f
Make the code a bit clearer by making it clear
c8bd4f
we are subtracting the size of the EFI_GUID member
c8bd4f
from the EFI_SIGNATURE_DATA size.
c8bd4f
c8bd4f
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
c8bd4f
---
c8bd4f
 lib/tpm2_eventlog_yaml.c | 12 ++++++------
c8bd4f
 1 file changed, 6 insertions(+), 6 deletions(-)
c8bd4f
c8bd4f
diff --git a/lib/tpm2_eventlog_yaml.c b/lib/tpm2_eventlog_yaml.c
c8bd4f
index 647a2225..fee78027 100644
c8bd4f
--- a/lib/tpm2_eventlog_yaml.c
c8bd4f
+++ b/lib/tpm2_eventlog_yaml.c
c8bd4f
@@ -374,13 +374,13 @@ static bool yaml_uefi_var(UEFI_VARIABLE_DATA *data, size_t size, UINT32 type,
c8bd4f
                     for (i = 0; i < signatures; i++) {
c8bd4f
                         EFI_SIGNATURE_DATA *s = (EFI_SIGNATURE_DATA *)signature;
c8bd4f
                         char *sdata = calloc (1,
c8bd4f
-                            BYTES_TO_HEX_STRING_SIZE(slist->SignatureSize-16));
c8bd4f
+                            BYTES_TO_HEX_STRING_SIZE(slist->SignatureSize - sizeof(EFI_GUID)));
c8bd4f
                         if (sdata == NULL) {
c8bd4f
                             LOG_ERR("Failled to allocate data: %s\n", strerror(errno));
c8bd4f
                             return false;
c8bd4f
                         }
c8bd4f
-                        bytes_to_str(s->SignatureData, slist->SignatureSize-16,
c8bd4f
-                            sdata, BYTES_TO_HEX_STRING_SIZE(slist->SignatureSize-16));
c8bd4f
+                        bytes_to_str(s->SignatureData, slist->SignatureSize - sizeof(EFI_GUID),
c8bd4f
+                            sdata, BYTES_TO_HEX_STRING_SIZE(slist->SignatureSize - sizeof(EFI_GUID)));
c8bd4f
                         guid_unparse_lower(s->SignatureOwner, uuidstr);
c8bd4f
                         tpm2_tool_output("      - SignatureOwner: %s\n"
c8bd4f
                                          "        SignatureData: %s\n",
c8bd4f
@@ -426,13 +426,13 @@ static bool yaml_uefi_var(UEFI_VARIABLE_DATA *data, size_t size, UINT32 type,
c8bd4f
             EFI_SIGNATURE_DATA *s= (EFI_SIGNATURE_DATA *)&data->UnicodeName[
c8bd4f
                 data->UnicodeNameLength];
c8bd4f
             char *sdata = calloc (1,
c8bd4f
-                BYTES_TO_HEX_STRING_SIZE(data->VariableDataLength - 16));
c8bd4f
+                BYTES_TO_HEX_STRING_SIZE(data->VariableDataLength - sizeof(EFI_GUID)));
c8bd4f
             if (sdata == NULL) {
c8bd4f
                 LOG_ERR("Failled to allocate data: %s\n", strerror(errno));
c8bd4f
                 return false;
c8bd4f
             }
c8bd4f
-            bytes_to_str(s->SignatureData, data->VariableDataLength - 16,
c8bd4f
-                sdata, BYTES_TO_HEX_STRING_SIZE(data->VariableDataLength - 16));
c8bd4f
+            bytes_to_str(s->SignatureData, data->VariableDataLength - sizeof(EFI_GUID),
c8bd4f
+                sdata, BYTES_TO_HEX_STRING_SIZE(data->VariableDataLength - sizeof(EFI_GUID)));
c8bd4f
             guid_unparse_lower(s->SignatureOwner, uuidstr);
c8bd4f
             tpm2_tool_output("    - SignatureOwner: %s\n"
c8bd4f
                              "      SignatureData: %s\n",
c8bd4f
-- 
c8bd4f
2.37.3
c8bd4f