[llvm] ebee5e0 - [Object] Always initialized StartOfFile in Archive::Child::Child constructor.
Thurston Dang via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 21 17:04:47 PDT 2023
Author: Jacek Caban
Date: 2023-04-22T00:04:30Z
New Revision: ebee5e0473df7685086eb2f4ffb07e1bf965b3bd
URL: https://github.com/llvm/llvm-project/commit/ebee5e0473df7685086eb2f4ffb07e1bf965b3bd
DIFF: https://github.com/llvm/llvm-project/commit/ebee5e0473df7685086eb2f4ffb07e1bf965b3bd.diff
LOG: [Object] Always initialized StartOfFile in Archive::Child::Child constructor.
Fixes uninitialized memory access revealed by https://reviews.llvm.org/D146534.
In empty archives, we use Child(nullptr,nullptr,nullptr) in Archive constructor in setFirstRegular. This copies unitialized StartOfFile to FirstRegularStartOfFile, which child_begin may use later.
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D148955
Added:
Modified:
llvm/lib/Object/Archive.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp
index 6ddbe3518d8e9..081ff79ff550c 100644
--- a/llvm/lib/Object/Archive.cpp
+++ b/llvm/lib/Object/Archive.cpp
@@ -468,6 +468,7 @@ Archive::Child::Child(const Archive *Parent, const char *Start, Error *Err)
: Parent(Parent) {
if (!Start) {
Header = nullptr;
+ StartOfFile = -1;
return;
}
More information about the llvm-commits
mailing list