]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootspec: automatically filter non-native UKIs and add-ons when enumerating 34347/head
authorLennart Poettering <lennart@poettering.net>
Fri, 5 Jul 2024 14:17:27 +0000 (16:17 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 12 Sep 2024 08:02:15 +0000 (10:02 +0200)
src/shared/bootspec.c

index a74204f11916ae8a556fbef2264b391f7d4cdc99..50a07400fe3348e10d9d4f218840f150d4f2397f 100644 (file)
@@ -930,6 +930,9 @@ static int pe_find_uki_sections(
         if (!pe_is_uki(pe_header, sections))
                 return log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Parsed PE file '%s' is not a UKI.", path);
 
+        if (!pe_is_native(pe_header)) /* Don't process non-native UKIs */
+                goto nothing;
+
         /* Find part of the section table for this profile */
         size_t n_psections = 0;
         const IMAGE_SECTION_HEADER *psections = pe_find_profile_section_table(pe_header, sections, profile, &n_psections);
@@ -1004,9 +1007,12 @@ static int pe_find_addon_sections(
         if (!pe_is_addon(pe_header, sections))
                 return log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Parse PE file '%s' is not an add-on.", path);
 
-        /* Define early, before the goto below */
+        /* Define early, before the gotos below */
         _cleanup_free_ char *cmdline_text = NULL;
 
+        if (!pe_is_native(pe_header))
+                goto nothing;
+
         const IMAGE_SECTION_HEADER *found = pe_section_table_find(sections, le16toh(pe_header->pe.NumberOfSections), ".cmdline");
         if (!found)
                 goto nothing;