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

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