summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2021-10-26 12:25:41 +0200
committerJan Janssen <medhefgo@web.de>2021-11-04 18:37:07 +0100
commitff9d65f6ffa72a28911ce53bcb7ac5dd277e218a (patch)
tree080a8440e4dfe2a9155962f6551c1487844b8e3f /src
parentsd-boot: Use FLAGS_SET (diff)
downloadsystemd-ff9d65f6ffa72a28911ce53bcb7ac5dd277e218a.tar.xz
systemd-ff9d65f6ffa72a28911ce53bcb7ac5dd277e218a.zip
sd-boot: Move optional header verification into verify_pe
Diffstat (limited to 'src')
-rw-r--r--src/boot/efi/pe.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/boot/efi/pe.c b/src/boot/efi/pe.c
index 6aecfe4526..e87b720dfa 100644
--- a/src/boot/efi/pe.c
+++ b/src/boot/efi/pe.c
@@ -122,7 +122,8 @@ static inline BOOLEAN verify_pe(const struct PeFileHeader *pe) {
return CompareMem(pe->Magic, PE_FILE_MAGIC, STRLEN(PE_FILE_MAGIC)) == 0 &&
pe->FileHeader.Machine == TARGET_MACHINE_TYPE &&
pe->FileHeader.NumberOfSections > 0 &&
- pe->FileHeader.NumberOfSections <= MAX_SECTIONS;
+ pe->FileHeader.NumberOfSections <= MAX_SECTIONS &&
+ IN_SET(pe->OptionalHeader.Magic, OPTHDR32_MAGIC, OPTHDR64_MAGIC);
}
static inline UINTN section_table_offset(const struct DosFileHeader *dos, const struct PeFileHeader *pe) {
@@ -182,15 +183,8 @@ EFI_STATUS pe_alignment_info(
return EFI_LOAD_ERROR;
*ret_entry_point_address = pe->OptionalHeader.AddressOfEntryPoint;
-
- if (pe->OptionalHeader.Magic == OPTHDR32_MAGIC) {
- *ret_size_of_image = pe->OptionalHeader.SizeOfImage;
- *ret_section_alignment = pe->OptionalHeader.SectionAlignment;
- } else if (pe->OptionalHeader.Magic == OPTHDR64_MAGIC) {
- *ret_size_of_image = pe->OptionalHeader.SizeOfImage;
- *ret_section_alignment = pe->OptionalHeader.SectionAlignment;
- } else
- return EFI_UNSUPPORTED;
+ *ret_size_of_image = pe->OptionalHeader.SizeOfImage;
+ *ret_section_alignment = pe->OptionalHeader.SectionAlignment;
return EFI_SUCCESS;
}