summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorragavarshinib <ragavarshinib@ami.com>2024-08-29 16:10:26 +0530
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-09-06 06:54:46 +0000
commit253b3d678aa541b24a2e05f2279975de06abfeec (patch)
treef1ae404732bf6cbedd95c31f6de54b4880b3f02d /MdeModulePkg
parent9dabe005f0cd422068fbb6cb915cf8180c55918d (diff)
downloadedk2-253b3d678aa541b24a2e05f2279975de06abfeec.tar.gz
edk2-253b3d678aa541b24a2e05f2279975de06abfeec.tar.bz2
edk2-253b3d678aa541b24a2e05f2279975de06abfeec.zip
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 <ragavarshinib@ami.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Dhanaraj V <vdhanaraj@ami.com> Cc: Sachin Ganesh <sachinganesh@ami.com>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Core/Pei/FwVol/FwVol.c12
1 files changed, 12 insertions, 0 deletions
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