From 253b3d678aa541b24a2e05f2279975de06abfeec Mon Sep 17 00:00:00 2001 From: ragavarshinib Date: Thu, 29 Aug 2024 16:10:26 +0530 Subject: [PATCH] MdeModulePkg/Core/Pei: Add error handling for Section Length This patch breaks the section processing loop if an invalid section with zero SectionLength is encountered. Signed-off-by: Ragavarshini B Cc: Liming Gao Cc: Dhanaraj V Cc: Sachin Ganesh --- MdeModulePkg/Core/Pei/FwVol/FwVol.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c index f7cc94c6eb..04bec986e4 100644 --- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c @@ -819,6 +819,10 @@ ProcessSection ( if (!IsFfs3Fv) { DEBUG ((DEBUG_ERROR, "Found a FFS3 formatted section in a non-FFS3 formatted FV.\n")); SectionLength = SECTION2_SIZE (Section); + if (SectionLength == 0) { + break; + } + // // SectionLength is adjusted it is 4 byte aligned. // Go to the next section @@ -854,6 +858,10 @@ ProcessSection ( SectionLength = SECTION_SIZE (Section); } + if (SectionLength == 0) { + break; + } + // // SectionLength is adjusted it is 4 byte aligned. // Go to the next section @@ -991,6 +999,10 @@ ProcessSection ( SectionLength = SECTION_SIZE (Section); } + if (SectionLength == 0) { + break; + } + // // SectionLength is adjusted it is 4 byte aligned. // Go to the next section