aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/Archive.cpp
diff options
context:
space:
mode:
authorJames Henderson <james.henderson@sony.com>2020-03-06 14:25:32 +0000
committerJames Henderson <james.henderson@sony.com>2020-03-11 10:29:45 +0000
commit326bc1da45b22110a11e0578022829a263ed4311 (patch)
treeb3276c36d06804fc8257a0978c3a067c55a582ba /llvm/lib/Object/Archive.cpp
parenta6d3bec83fca0568e1fb02b9297b43435b9579d6 (diff)
downloadllvm-326bc1da45b22110a11e0578022829a263ed4311.zip
llvm-326bc1da45b22110a11e0578022829a263ed4311.tar.gz
llvm-326bc1da45b22110a11e0578022829a263ed4311.tar.bz2
[Object] Fix handling of large archive members
The archive library truncated the size of archive members whose size was greater than max uint32_t. This patch fixes the issue and adds some unit tests to verify. Reviewed by: ruiu, MaskRay, grimar, rupprecht Differential Revision: https://reviews.llvm.org/D75742
Diffstat (limited to 'llvm/lib/Object/Archive.cpp')
-rw-r--r--llvm/lib/Object/Archive.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp
index 17d5eec..c18dd11 100644
--- a/llvm/lib/Object/Archive.cpp
+++ b/llvm/lib/Object/Archive.cpp
@@ -392,12 +392,8 @@ Archive::Child::Child(const Archive *Parent, const char *Start, Error *Err)
}
Expected<uint64_t> Archive::Child::getSize() const {
- if (Parent->IsThin) {
- Expected<uint32_t> Size = Header.getSize();
- if (!Size)
- return Size.takeError();
- return Size.get();
- }
+ if (Parent->IsThin)
+ return Header.getSize();
return Data.size() - StartOfFile;
}
@@ -437,7 +433,7 @@ Expected<StringRef> Archive::Child::getBuffer() const {
return isThinOrErr.takeError();
bool isThin = isThinOrErr.get();
if (!isThin) {
- Expected<uint32_t> Size = getSize();
+ Expected<uint64_t> Size = getSize();
if (!Size)
return Size.takeError();
return StringRef(Data.data() + StartOfFile, Size.get());