summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2019-05-13 16:34:35 -0400
committerPeter Jones <pjones@redhat.com>2020-07-23 20:52:12 -0400
commit2cbf56b82a5102777b37c4f7f47c8cf058cea027 (patch)
tree7acc9097a20ff9c8e5d5bc344850c431a0170dad
parentb5e10f70c7a495dc1788e3604803ee633f1e5f76 (diff)
downloadefi-boot-shim-2cbf56b82a5102777b37c4f7f47c8cf058cea027.tar.gz
efi-boot-shim-2cbf56b82a5102777b37c4f7f47c8cf058cea027.zip
Work around stuff -Waddress-of-packed-member finds.
In MokManager we get a lot of these: ../src/MokManager.c:1063:19: error: taking address of packed member of ‘struct <anonymous>’ may result in an unaligned pointer value [-Werror=address-of-packed-member] 1063 | if (CompareGuid(&(list[i].Type), &X509_GUID) == 0) | ^~~~~~~~~~~~~~~ The reason for this is that gnu-efi takes EFI_GUID * as its argument instead of VOID *, and there's nothing telling the compiler that it doesn't have alignment constraints on the input, so the compiler wants it to have 16-byte alignment. Just use CompareMem() for these, as that's all CompareGuid is calling anyway. Signed-off-by: Peter Jones <pjones@redhat.com> Upstream-commit-id: 08c14376b59
-rw-r--r--MokManager.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/MokManager.c b/MokManager.c
index df9b6fe6..a1bd39a6 100644
--- a/MokManager.c
+++ b/MokManager.c
@@ -22,6 +22,8 @@
#define CERT_STRING L"Select an X509 certificate to enroll:\n\n"
#define HASH_STRING L"Select a file to trust:\n\n"
+#define CompareMemberGuid(x, y) CompareMem(x, y, sizeof(EFI_GUID))
+
typedef struct {
UINT32 MokSize;
UINT8 *Mok;
@@ -1077,7 +1079,7 @@ static EFI_STATUS write_back_mok_list(MokListNode * list, INTN key_num,
continue;
DataSize += sizeof(EFI_SIGNATURE_LIST);
- if (CompareGuid(&(list[i].Type), &X509_GUID) == 0)
+ if (CompareMemberGuid(&(list[i].Type), &X509_GUID) == 0)
DataSize += sizeof(EFI_GUID);
DataSize += list[i].MokSize;
}
@@ -1099,7 +1101,7 @@ static EFI_STATUS write_back_mok_list(MokListNode * list, INTN key_num,
CertList->SignatureType = list[i].Type;
CertList->SignatureHeaderSize = 0;
- if (CompareGuid(&(list[i].Type), &X509_GUID) == 0) {
+ if (CompareMemberGuid(&(list[i].Type), &X509_GUID) == 0) {
CertList->SignatureListSize = list[i].MokSize +
sizeof(EFI_SIGNATURE_LIST) + sizeof(EFI_GUID);
CertList->SignatureSize =
@@ -1140,7 +1142,7 @@ static void delete_cert(void *key, UINT32 key_size,
int i;
for (i = 0; i < mok_num; i++) {
- if (CompareGuid(&(mok[i].Type), &X509_GUID) != 0)
+ if (CompareMemberGuid(&(mok[i].Type), &X509_GUID) != 0)
continue;
if (mok[i].MokSize == key_size &&
@@ -1191,7 +1193,7 @@ 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 ((CompareGuid(&(mok[i].Type), &Type) != 0) ||
+ if ((CompareMemberGuid(&(mok[i].Type), &Type) != 0) ||
(mok[i].MokSize < sig_size))
continue;
@@ -1355,7 +1357,7 @@ static EFI_STATUS delete_keys(void *MokDel, UINTN MokDelSize, BOOLEAN MokX)
/* Search and destroy */
for (i = 0; i < del_num; i++) {
- if (CompareGuid(&(del_key[i].Type), &X509_GUID) == 0) {
+ if (CompareMemberGuid(&(del_key[i].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)) {