]> granicus.if.org Git - llvm/commitdiff
Extra error checking to ARMAttributeParser
authorEugene Leviant <eleviant@accesssoftek.com>
Thu, 13 Jun 2019 13:25:20 +0000 (13:25 +0000)
committerEugene Leviant <eleviant@accesssoftek.com>
Thu, 13 Jun 2019 13:25:20 +0000 (13:25 +0000)
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

index 08b939a8734652350ff2e9d4714d2d99646744e9..65ee51f13190688bb287f691728f81b374bd2243 100644 (file)
@@ -709,6 +709,12 @@ void ARMAttributeParser::Parse(ArrayRef<uint8_t> 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;