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:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user