From 4ff0ca62e507e8fdbd5e0dfeed8acda407a36e56 Mon Sep 17 00:00:00 2001 From: Eugene Leviant Date: Thu, 13 Jun 2019 13:25:20 +0000 Subject: [PATCH] Extra error checking to ARMAttributeParser The patch checks for subsection length as discussed in D63191 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363260 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/ARMAttributeParser.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Support/ARMAttributeParser.cpp b/lib/Support/ARMAttributeParser.cpp index 08b939a8734..65ee51f1319 100644 --- a/lib/Support/ARMAttributeParser.cpp +++ b/lib/Support/ARMAttributeParser.cpp @@ -709,6 +709,12 @@ void ARMAttributeParser::Parse(ArrayRef Section, bool isLittle) { SW->indent(); } + if (SectionLength == 0 || (SectionLength + Offset) > Section.size()) { + errs() << "invalid subsection length " << SectionLength << " at offset " + << Offset << "\n"; + return; + } + ParseSubsection(Section.data() + Offset, SectionLength); Offset = Offset + SectionLength; -- 2.40.0