Skip to content

Commit b26fe2a

Browse files
author
Kai Luo
committed
[AIX][BigArchive] Treat the archive is empty if the first child member offset is zero
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
1 parent 14ce58f commit b26fe2a

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

llvm/include/llvm/Object/Archive.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,7 @@ class BigArchive : public Archive {
413413
BigArchive(MemoryBufferRef Source, Error &Err);
414414
uint64_t getFirstChildOffset() const override { return FirstChildOffset; }
415415
uint64_t getLastChildOffset() const { return LastChildOffset; }
416-
bool isEmpty() const override {
417-
return Data.getBufferSize() == sizeof(FixLenHdr);
418-
};
416+
bool isEmpty() const override { return getFirstChildOffset() == 0; }
419417
};
420418

421419
} // end namespace object
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Test reading an empty archive with first member's offset is not zero.
2+
# RUN: echo "<bigaf>" > %t.a
3+
# RUN: echo -n "0 0 0 128 0 0 " >> %t.a
4+
# RUN: not llvm-ar tv %t.a 2>&1 | grep 'truncated or malformed archive'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Test reading an empty archive with free list in it.
2-
# RUN: not llvm-ar tv %p/Inputs/aix-empty-big-archive-with-freelist.a 2>&1 \
3-
# RUN: | grep 'truncated or malformed archive'
2+
# RUN: llvm-ar tv %p/Inputs/aix-empty-big-archive-with-freelist.a 2>&1 \
3+
# RUN: | not grep 'truncated or malformed archive'

0 commit comments

Comments
 (0)