From e79cea6fbef5bf471f82fc3b8786d319b98bbdd8 Mon Sep 17 00:00:00 2001
From: Luca Boccassi <luca.boccassi@gmail.com>
Date: Fri, 10 Jan 2025 21:02:55 +0000
Subject: [PATCH 1087/1160] stub: drop PE sections parsing cap

This was added originally as it was thought that Windows applied
the same cap. Nowadays the specs do not mention it, and it is
believed Windows no longer applies it either, so drop it in order
to allow an arbitrary number of DTBs to be included

Fixes https://github.com/systemd/systemd/issues/35943

(cherry picked from commit 8c5b359579b0f1029edafb0bd96b5ebfb271db76)
(cherry picked from commit 95184817cb3ac3d3d2582496ccbfc3802cc0f245)
(cherry picked from commit 5cbe2b8e9e247670cdebed1cc9bd1d7144ca0cca)
---
 src/boot/efi/pe.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/boot/efi/pe.c b/src/boot/efi/pe.c
index fdca0c93fe..e3c568914a 100644
--- a/src/boot/efi/pe.c
+++ b/src/boot/efi/pe.c
@@ -5,7 +5,6 @@
 
 #define DOS_FILE_MAGIC "MZ"
 #define PE_FILE_MAGIC  "PE\0\0"
-#define MAX_SECTIONS 96
 
 #if defined(__i386__)
 #  define TARGET_MACHINE_TYPE 0x014CU
@@ -130,7 +129,6 @@ static bool verify_pe(const PeFileHeader *pe, bool allow_compatibility) {
                (pe->FileHeader.Machine == TARGET_MACHINE_TYPE ||
                 (allow_compatibility && pe->FileHeader.Machine == TARGET_MACHINE_TYPE_COMPATIBILITY)) &&
                pe->FileHeader.NumberOfSections > 0 &&
-               pe->FileHeader.NumberOfSections <= MAX_SECTIONS &&
                IN_SET(pe->OptionalHeader.Magic, OPTHDR32_MAGIC, OPTHDR64_MAGIC);
 }
 
-- 
2.33.0