Skip to content

Commit 98b36ef

Browse files
mokutil: Bring in upstream patches for build issues
Bring in two patches from upstream to resolve build issues with newer compilers. Signed-off-by: Chris Packham <[email protected]>
1 parent b76bc58 commit 98b36ef

File tree

3 files changed

+174
-1
lines changed

3 files changed

+174
-1
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
From 7e5d2180c09429955004f3dfd960293a39aaf731 Mon Sep 17 00:00:00 2001
2+
From: Harry Youd <[email protected]>
3+
Date: Wed, 31 Jul 2019 19:44:53 +0100
4+
Subject: [PATCH] Avoid taking pointer to packed struct
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=UTF-8
7+
Content-Transfer-Encoding: 8bit
8+
9+
Fixes:
10+
error: taking address of packed member of ‘struct <anonymous>’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
11+
(cherry picked from commit 19e8c9071b3d9306ca7b7329b313b31f86c2936d)
12+
---
13+
src/mokutil.c | 38 ++++++++++++++++++++++----------------
14+
1 file changed, 22 insertions(+), 16 deletions(-)
15+
16+
diff --git a/src/mokutil.c b/src/mokutil.c
17+
index e2d567d..8892613 100644
18+
--- a/src/mokutil.c
19+
+++ b/src/mokutil.c
20+
@@ -270,20 +270,22 @@ build_mok_list (void *data, unsigned long data_size, uint32_t *mok_num)
21+
return NULL;
22+
}
23+
24+
- if ((efi_guid_cmp (&CertList->SignatureType, &efi_guid_x509_cert) != 0) &&
25+
- (efi_guid_cmp (&CertList->SignatureType, &efi_guid_sha1) != 0) &&
26+
- (efi_guid_cmp (&CertList->SignatureType, &efi_guid_sha224) != 0) &&
27+
- (efi_guid_cmp (&CertList->SignatureType, &efi_guid_sha256) != 0) &&
28+
- (efi_guid_cmp (&CertList->SignatureType, &efi_guid_sha384) != 0) &&
29+
- (efi_guid_cmp (&CertList->SignatureType, &efi_guid_sha512) != 0)) {
30+
+ efi_guid_t sigtype = CertList->SignatureType;
31+
+
32+
+ if ((efi_guid_cmp (&sigtype, &efi_guid_x509_cert) != 0) &&
33+
+ (efi_guid_cmp (&sigtype, &efi_guid_sha1) != 0) &&
34+
+ (efi_guid_cmp (&sigtype, &efi_guid_sha224) != 0) &&
35+
+ (efi_guid_cmp (&sigtype, &efi_guid_sha256) != 0) &&
36+
+ (efi_guid_cmp (&sigtype, &efi_guid_sha384) != 0) &&
37+
+ (efi_guid_cmp (&sigtype, &efi_guid_sha512) != 0)) {
38+
dbsize -= CertList->SignatureListSize;
39+
CertList = (EFI_SIGNATURE_LIST *)((uint8_t *) CertList +
40+
CertList->SignatureListSize);
41+
continue;
42+
}
43+
44+
- if ((efi_guid_cmp (&CertList->SignatureType, &efi_guid_x509_cert) != 0) &&
45+
- (CertList->SignatureSize != signature_size (&CertList->SignatureType))) {
46+
+ if ((efi_guid_cmp (&sigtype, &efi_guid_x509_cert) != 0) &&
47+
+ (CertList->SignatureSize != signature_size (&sigtype))) {
48+
dbsize -= CertList->SignatureListSize;
49+
CertList = (EFI_SIGNATURE_LIST *)((uint8_t *) CertList +
50+
CertList->SignatureListSize);
51+
@@ -312,7 +314,7 @@ build_mok_list (void *data, unsigned long data_size, uint32_t *mok_num)
52+
}
53+
54+
list[count].header = CertList;
55+
- if (efi_guid_cmp (&CertList->SignatureType, &efi_guid_x509_cert) == 0) {
56+
+ if (efi_guid_cmp (&sigtype, &efi_guid_x509_cert) == 0) {
57+
/* X509 certificate */
58+
list[count].mok_size = CertList->SignatureSize -
59+
sizeof(efi_guid_t);
60+
@@ -442,10 +444,11 @@ list_keys (uint8_t *data, size_t data_size)
61+
62+
for (unsigned int i = 0; i < mok_num; i++) {
63+
printf ("[key %d]\n", i+1);
64+
- if (efi_guid_cmp (&list[i].header->SignatureType, &efi_guid_x509_cert) == 0) {
65+
+ efi_guid_t sigtype = list[i].header->SignatureType;
66+
+ if (efi_guid_cmp (&sigtype, &efi_guid_x509_cert) == 0) {
67+
print_x509 ((char *)list[i].mok, list[i].mok_size);
68+
} else {
69+
- print_hash_array (&list[i].header->SignatureType,
70+
+ print_hash_array (&sigtype,
71+
list[i].mok, list[i].mok_size);
72+
}
73+
if (i < mok_num - 1)
74+
@@ -523,7 +526,8 @@ delete_data_from_list (const efi_guid_t *var_guid, const char *var_name,
75+
remain = total;
76+
for (unsigned int i = 0; i < mok_num; i++) {
77+
remain -= list[i].header->SignatureListSize;
78+
- if (efi_guid_cmp (&list[i].header->SignatureType, type) != 0)
79+
+ efi_guid_t sigtype = list[i].header->SignatureType;
80+
+ if (efi_guid_cmp (&sigtype, type) != 0)
81+
continue;
82+
83+
sig_list_size = list[i].header->SignatureListSize;
84+
@@ -1057,7 +1061,8 @@ is_duplicate (const efi_guid_t *type, const void *data, const uint32_t data_size
85+
}
86+
87+
for (unsigned int i = 0; i < node_num; i++) {
88+
- if (efi_guid_cmp (&list[i].header->SignatureType, type) != 0)
89+
+ efi_guid_t sigtype = list[i].header->SignatureType;
90+
+ if (efi_guid_cmp (&sigtype, type) != 0)
91+
continue;
92+
93+
if (efi_guid_cmp (type, &efi_guid_x509_cert) == 0) {
94+
@@ -1510,8 +1515,8 @@ issue_hash_request (const char *hash_str, MokRequest req,
95+
goto error;
96+
/* Check if there is a signature list with the same type */
97+
for (unsigned int i = 0; i < mok_num; i++) {
98+
- if (efi_guid_cmp (&mok_list[i].header->SignatureType,
99+
- &hash_type) == 0) {
100+
+ efi_guid_t sigtype = mok_list[i].header->SignatureType;
101+
+ if (efi_guid_cmp (&sigtype, &hash_type) == 0) {
102+
merge_ind = i;
103+
list_size -= sizeof(EFI_SIGNATURE_LIST);
104+
break;
105+
@@ -1678,8 +1683,9 @@ export_db_keys (const DBName db_name)
106+
for (unsigned i = 0; i < mok_num; i++) {
107+
off_t offset = 0;
108+
ssize_t write_size;
109+
+ efi_guid_t sigtype = list[i].header->SignatureType;
110+
111+
- if (efi_guid_cmp (&list[i].header->SignatureType, &efi_guid_x509_cert) != 0)
112+
+ if (efi_guid_cmp (&sigtype, &efi_guid_x509_cert) != 0)
113+
continue;
114+
115+
/* Dump X509 certificate to files */
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
From 6b1d030983d012bfdc6e8b9269af4e4de21684cb Mon Sep 17 00:00:00 2001
2+
From: Nicolas Frayer <[email protected]>
3+
Date: Wed, 29 Jan 2025 17:37:36 +0100
4+
Subject: [PATCH] mokutil: remove unused int_to_b64()
5+
6+
static const char b64t[64] triggers compiler warning
7+
which in turn makes the build fail with
8+
-Werror=unterminated-string-initialization, so removing
9+
this string with the the unused int_to_b64() function
10+
which is the only function using this array.
11+
12+
Signed-off-by: Nicolas Frayer <[email protected]>
13+
(cherry picked from commit ea98ef56fa64e088d968a10c7bc751492abe672f)
14+
---
15+
src/password-crypt.c | 9 ---------
16+
src/password-crypt.h | 1 -
17+
2 files changed, 10 deletions(-)
18+
19+
diff --git a/src/password-crypt.c b/src/password-crypt.c
20+
index 0b31d64..a4225f0 100644
21+
--- a/src/password-crypt.c
22+
+++ b/src/password-crypt.c
23+
@@ -46,9 +46,6 @@
24+
#define SHA256_DEFAULT_ROUNDS 5000
25+
#define SHA512_DEFAULT_ROUNDS 5000
26+
27+
-static const char b64t[64] =
28+
-"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
29+
-
30+
static const char md5_prefix[] = "$1$";
31+
32+
static const char sha256_prefix[] = "$5$";
33+
@@ -357,12 +354,6 @@ decode_pass (const char *crypt_pass, pw_crypt_t *pw_crypt)
34+
return -1;
35+
}
36+
37+
-char
38+
-int_to_b64 (const int i)
39+
-{
40+
- return b64t[i & 0x3f];
41+
-}
42+
-
43+
int
44+
b64_to_int (const char c)
45+
{
46+
diff --git a/src/password-crypt.h b/src/password-crypt.h
47+
index 5487363..572f9ce 100644
48+
--- a/src/password-crypt.h
49+
+++ b/src/password-crypt.h
50+
@@ -68,7 +68,6 @@ uint16_t get_salt_size (int method);
51+
int get_hash_size (int method);
52+
const char *get_crypt_prefix (int method);
53+
int decode_pass (const char *crypt_pass, pw_crypt_t *pw_crypt);
54+
-char int_to_b64 (const int i);
55+
int b64_to_int (const char c);
56+
57+
#endif /* __PASSWORD_CRYPT_H__ */

patches/mokutil/series

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
# New version of mokutil has patches for 3.0 already, so nothing to do here yet...
1+
0001-Avoid-taking-pointer-to-packed-struct.patch
2+
0002-mokutil-remove-unused-int_to_b64.patch

0 commit comments

Comments
 (0)