]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pe-binary: actually check if PE binary is UEFI binary when determining if UKI
authorLennart Poettering <lennart@poettering.net>
Fri, 29 Sep 2023 16:55:31 +0000 (18:55 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 29 Sep 2023 19:54:16 +0000 (21:54 +0200)
If it's not a UEFI binary, then it's not a UKI.

src/shared/pe-binary.c
src/shared/pe-binary.h

index 6a6b8adb86f8d2dfe37ac6872a9078903395bbd1..4c05323d951a5286ac812014f7dc49823f84ff01 100644 (file)
@@ -231,6 +231,9 @@ bool pe_is_uki(const PeHeader *pe_header, const IMAGE_SECTION_HEADER *sections)
         assert(pe_header);
         assert(sections || le16toh(pe_header->pe.NumberOfSections) == 0);
 
+        if (le16toh(pe_header->optional.Subsystem) != IMAGE_SUBSYSTEM_EFI_APPLICATION)
+                return false;
+
         return
                 pe_header_find_section(pe_header, sections, ".osrel") &&
                 pe_header_find_section(pe_header, sections, ".linux") &&
index 758bb1de83eae5806e7e5a2ecc2d42773322e730..2ef44d7e492e3d7b4d83a17e0348650aecd51e41 100644 (file)
@@ -123,6 +123,8 @@ typedef struct _packed_ _IMAGE_SECTION_HEADER {
         le32_t Characteristics;
 } IMAGE_SECTION_HEADER;
 
+#define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
+
 bool pe_header_is_64bit(const PeHeader *h);
 
 #define PE_HEADER_OPTIONAL_FIELD(h, field)                           \