/// Members are not larger than 4GB.
uint32_t getSize() const;
+ bool isSizeValid() const;
sys::fs::perms getAccessMode() const;
sys::TimeValue getLastModified() const;
return Ret;
}
+bool ArchiveMemberHeader::isSizeValid() const {
+ uint32_t Ret;
+ if (llvm::StringRef(Size, sizeof(Size)).rtrim(" ").getAsInteger(10, Ret))
+ return false;
+ return true;
+}
+
sys::fs::perms ArchiveMemberHeader::getAccessMode() const {
unsigned Ret;
if (StringRef(AccessMode, sizeof(AccessMode)).rtrim(" ").getAsInteger(8, Ret))
uint64_t Size = sizeof(ArchiveMemberHeader);
Data = StringRef(Start, Size);
+ // Check to make sure the size is valid.
+ const ArchiveMemberHeader *Header =
+ reinterpret_cast<const ArchiveMemberHeader *>(Data.data());
+ if (!Header->isSizeValid())
+ return;
if (!isThinMember()) {
Size += getRawSize();
Data = StringRef(Start, Size);
# RUN: | FileCheck -check-prefix=m0337 %s
# m0337: subq $16, %rsp
+
+# RUN: llvm-objdump -macho -disassemble \
+# RUN: %p/Inputs/malformed-machos/00000031.a \
+# RUN: | FileCheck -check-prefix=0031a %s
+
+# 0031a: Archive