Overflow was the reason of incorrect passing the check,
patch fixes the case.
Differentail revision: https://reviews.llvm.org/D25514
llvm-svn: 285284
if (Size % sizeof(T))
return object_error::parse_failed;
- if (Offset + Size > Buf.size())
+ if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
+ Offset + Size > Buf.size())
return object_error::parse_failed;
const T *Start = reinterpret_cast<const T *>(base() + Offset);
RUN: not llvm-readobj -t %p/Inputs/invalid-sections-address-alignment.x86-64 2>&1 | \
RUN: FileCheck --check-prefix=INVALID-SEC-ADDRESS-ALIGNMENT %s
INVALID-SEC-ADDRESS-ALIGNMENT: Invalid data was encountered while parsing the file
+
+RUN: not llvm-readobj -t %p/Inputs/invalid-section-size2.elf 2>&1 | \
+RUN: FileCheck --check-prefix=INVALID-SECTION-SIZE2 %s
+INVALID-SECTION-SIZE2: Invalid data was encountered while parsing the file.