112 lines
4.1 KiB
Diff
112 lines
4.1 KiB
Diff
From d57e53f3bddc4bc7299b3d5efd5ba8c547e8dfa5 Mon Sep 17 00:00:00 2001
|
||
From: Jonas Witschel <diabonas@gmx.de>
|
||
Date: Thu, 5 Sep 2019 10:39:37 +0200
|
||
Subject: [PATCH 40/62] MokManager: avoid -Werror=address-of-packed-member
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
When compiling with GCC 9, there are a couple of errors of the form
|
||
|
||
MokManager.c: In function ‘write_back_mok_list’:
|
||
MokManager.c:1056:19: error: taking address of packed member of ‘struct <anonymous>’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
|
||
1056 | if (CompareGuid(&(list[i].Type), &X509_GUID) == 0)
|
||
| ^~~~~~~~~~~~~~~
|
||
|
||
Copying the member of the packed struct to a temporary variable and
|
||
pointing to that variable solves the problem.
|
||
|
||
Upstream-commit-id: 58532e12e9a
|
||
---
|
||
MokManager.c | 22 +++++++++++++---------
|
||
1 file changed, 13 insertions(+), 9 deletions(-)
|
||
|
||
diff --git a/MokManager.c b/MokManager.c
|
||
index 78da9fd95ee..fa73e2fd865 100644
|
||
--- a/MokManager.c
|
||
+++ b/MokManager.c
|
||
@@ -1064,6 +1064,7 @@ static EFI_STATUS write_back_mok_list(MokListNode * list, INTN key_num,
|
||
EFI_STATUS efi_status;
|
||
EFI_SIGNATURE_LIST *CertList;
|
||
EFI_SIGNATURE_DATA *CertData;
|
||
+ EFI_GUID type;
|
||
void *Data = NULL, *ptr;
|
||
INTN DataSize = 0;
|
||
int i;
|
||
@@ -1079,8 +1080,8 @@ static EFI_STATUS write_back_mok_list(MokListNode * list, INTN key_num,
|
||
continue;
|
||
|
||
DataSize += sizeof(EFI_SIGNATURE_LIST);
|
||
- if (CompareMem(&(list[i].Type), &X509_GUID,
|
||
- sizeof(EFI_GUID)) == 0)
|
||
+ type = list[i].Type; /* avoid -Werror=address-of-packed-member */
|
||
+ if (CompareGuid(&type, &X509_GUID) == 0)
|
||
DataSize += sizeof(EFI_GUID);
|
||
DataSize += list[i].MokSize;
|
||
}
|
||
@@ -1102,8 +1103,7 @@ static EFI_STATUS write_back_mok_list(MokListNode * list, INTN key_num,
|
||
CertList->SignatureType = list[i].Type;
|
||
CertList->SignatureHeaderSize = 0;
|
||
|
||
- if (CompareMem(&(list[i].Type), &X509_GUID,
|
||
- sizeof(EFI_GUID)) == 0) {
|
||
+ if (CompareGuid(&(CertList->SignatureType), &X509_GUID) == 0) {
|
||
CertList->SignatureListSize = list[i].MokSize +
|
||
sizeof(EFI_SIGNATURE_LIST) + sizeof(EFI_GUID);
|
||
CertList->SignatureSize =
|
||
@@ -1141,11 +1141,12 @@ static EFI_STATUS write_back_mok_list(MokListNode * list, INTN key_num,
|
||
static void delete_cert(void *key, UINT32 key_size,
|
||
MokListNode * mok, INTN mok_num)
|
||
{
|
||
+ EFI_GUID type;
|
||
int i;
|
||
|
||
for (i = 0; i < mok_num; i++) {
|
||
- if (CompareMem(&(mok[i].Type), &X509_GUID,
|
||
- sizeof(EFI_GUID)) != 0)
|
||
+ type = mok[i].Type; /* avoid -Werror=address-of-packed-member */
|
||
+ if (CompareGuid(&type, &X509_GUID) != 0)
|
||
continue;
|
||
|
||
if (mok[i].MokSize == key_size &&
|
||
@@ -1187,6 +1188,7 @@ static void mem_move(void *dest, void *src, UINTN size)
|
||
static void delete_hash_in_list(EFI_GUID Type, UINT8 * hash, UINT32 hash_size,
|
||
MokListNode * mok, INTN mok_num)
|
||
{
|
||
+ EFI_GUID type;
|
||
UINT32 sig_size;
|
||
UINT32 list_num;
|
||
int i, del_ind;
|
||
@@ -1196,7 +1198,8 @@ static void delete_hash_in_list(EFI_GUID Type, UINT8 * hash, UINT32 hash_size,
|
||
sig_size = hash_size + sizeof(EFI_GUID);
|
||
|
||
for (i = 0; i < mok_num; i++) {
|
||
- if ((CompareMem(&(mok[i].Type), &Type, sizeof(EFI_GUID)) != 0) ||
|
||
+ type = mok[i].Type; /* avoid -Werror=address-of-packed-member */
|
||
+ if ((CompareGuid(&type, &Type) != 0) ||
|
||
(mok[i].MokSize < sig_size))
|
||
continue;
|
||
|
||
@@ -1252,6 +1255,7 @@ static void delete_hash_list(EFI_GUID Type, void *hash_list, UINT32 list_size,
|
||
static EFI_STATUS delete_keys(void *MokDel, UINTN MokDelSize, BOOLEAN MokX)
|
||
{
|
||
EFI_STATUS efi_status;
|
||
+ EFI_GUID type;
|
||
CHAR16 *db_name;
|
||
CHAR16 *auth_name;
|
||
CHAR16 *err_strs[] = { NULL, NULL, NULL };
|
||
@@ -1360,8 +1364,8 @@ static EFI_STATUS delete_keys(void *MokDel, UINTN MokDelSize, BOOLEAN MokX)
|
||
|
||
/* Search and destroy */
|
||
for (i = 0; i < del_num; i++) {
|
||
- if (CompareMem(&(del_key[i].Type), &X509_GUID,
|
||
- sizeof(EFI_GUID)) == 0) {
|
||
+ type = del_key[i].Type; /* avoid -Werror=address-of-packed-member */
|
||
+ if (CompareGuid(&type, &X509_GUID) == 0) {
|
||
delete_cert(del_key[i].Mok, del_key[i].MokSize,
|
||
mok, mok_num);
|
||
} else if (is_sha2_hash(del_key[i].Type)) {
|
||
--
|
||
2.26.2
|
||
|