bootctl: when updating everything check PE machine type

Let's never accidentally over-write foreign-arch PE binaries with native
ones.

Fixes: #33413
This commit is contained in:
Lennart Poettering
2025-06-20 14:06:53 +02:00
parent 95df8288c7
commit 6b8770b96b
3 changed files with 36 additions and 9 deletions
+11
View File
@@ -290,6 +290,17 @@ bool pe_is_native(const PeHeader *pe_header) {
#endif
}
int pe_is_native_fd(int fd) {
_cleanup_free_ PeHeader *pe_header = NULL;
int r;
r = pe_load_headers(fd, /* ret_dos_header= */ NULL, &pe_header);
if (r < 0)
return r;
return pe_is_native(pe_header);
}
/* Implements:
*
* https://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/authenticode_pe.docx
+1
View File
@@ -149,6 +149,7 @@ bool pe_is_uki(const PeHeader *pe_header, const IMAGE_SECTION_HEADER *sections);
bool pe_is_addon(const PeHeader *pe_header, const IMAGE_SECTION_HEADER *sections);
bool pe_is_native(const PeHeader *pe_header);
int pe_is_native_fd(int fd);
int pe_hash(int fd, const EVP_MD *md, void **ret_hash, size_t *ret_hash_size);