If the archive contains free list and contains no member file, the buffer length doesn't equal to length of the header.
Reviewed By: Esme, DiggerLin, #powerpc
Differential Revision: https://reviews.llvm.org/D138986
BigArchive(MemoryBufferRef Source, Error &Err);
uint64_t getFirstChildOffset() const override { return FirstChildOffset; }
uint64_t getLastChildOffset() const { return LastChildOffset; }
- bool isEmpty() const override {
- return Data.getBufferSize() == sizeof(FixLenHdr);
- };
+ bool isEmpty() const override { return getFirstChildOffset() == 0; }
};
} // end namespace object
--- /dev/null
+# Test reading an empty archive with first member's offset is not zero.
+# RUN: echo "<bigaf>" > %t.a
+# RUN: echo -n "0 0 0 128 0 0 " >> %t.a
+# RUN: not llvm-ar tv %t.a 2>&1 | grep 'truncated or malformed archive'
# Test reading an empty archive with free list in it.
-# RUN: not llvm-ar tv %p/Inputs/aix-empty-big-archive-with-freelist.a 2>&1 \
-# RUN: | grep 'truncated or malformed archive'
+# RUN: llvm-ar tv %p/Inputs/aix-empty-big-archive-with-freelist.a 2>&1 \
+# RUN: | not grep 'truncated or malformed archive'