From dac925cd5895b5d0262680adb9f80fe94dacaa65 Mon Sep 17 00:00:00 2001 From: Download-Fritz Date: Sat, 5 Jan 2019 15:37:46 +0100 Subject: [PATCH] Runtime-check whether the next section is in bounds to allow "!= NULL" loops. --- Library/OcMachoLib/Header.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Library/OcMachoLib/Header.c b/Library/OcMachoLib/Header.c index 78768bad..140bdbc9 100644 --- a/Library/OcMachoLib/Header.c +++ b/Library/OcMachoLib/Header.c @@ -591,9 +591,12 @@ MachoGetNextSection64 ( ASSERT (Segment != NULL); if (Section != NULL) { - ASSERT ((Section >= Segment->Sections) - && (Section < &Segment->Sections[Segment->NumSections]) - ); + ASSERT (Section >= Segment->Sections); + + if (Section >= &Segment->Sections[Segment->NumSections]) { + return NULL; + } + ++Section; } else { Section = &Segment->Sections[0];