summaryrefslogtreecommitdiff
path: root/src/buildtool
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-05-09 17:20:54 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-06-04 14:34:44 +0200
commit42e82b0f737de367de38567cbe6ee5f158618a2d (patch)
tree5dcdcf03eff236cf2e549c0c8ae38b9ffbc871fd /src/buildtool
parent8970cd4cbd4d75322d3c6132c6b440b194dcca89 (diff)
downloadjustbuild-42e82b0f737de367de38567cbe6ee5f158618a2d.tar.gz
GitTree: Ensure all read entries are valid
Match behaviour of reading trees, which always checks for invalid entries, also for reading blobs.
Diffstat (limited to 'src/buildtool')
-rw-r--r--src/buildtool/file_system/TARGETS1
-rw-r--r--src/buildtool/file_system/git_tree.cpp13
2 files changed, 9 insertions, 5 deletions
diff --git a/src/buildtool/file_system/TARGETS b/src/buildtool/file_system/TARGETS
index 87aa9e2c..d08d8451 100644
--- a/src/buildtool/file_system/TARGETS
+++ b/src/buildtool/file_system/TARGETS
@@ -103,7 +103,6 @@
[ ["src/buildtool/common", "common"]
, ["src/buildtool/logging", "log_level"]
, ["src/buildtool/logging", "logging"]
- , ["src/utils/cpp", "path"]
]
}
, "git_context":
diff --git a/src/buildtool/file_system/git_tree.cpp b/src/buildtool/file_system/git_tree.cpp
index ded027c2..ca0727fb 100644
--- a/src/buildtool/file_system/git_tree.cpp
+++ b/src/buildtool/file_system/git_tree.cpp
@@ -21,7 +21,6 @@
#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
-#include "src/utils/cpp/path.hpp"
namespace {
@@ -61,8 +60,11 @@ class SymlinksChecker final {
std::vector<ArtifactDigest> const& ids) const noexcept -> bool {
return std::all_of(
ids.begin(), ids.end(), [&cas = cas_](ArtifactDigest const& id) {
- auto content = cas.ReadObject(id.hash(), /*is_hex_id=*/true);
- return content.has_value() and PathIsNonUpwards(*content);
+ return cas
+ .ReadObject(id.hash(),
+ /*is_hex_id=*/true,
+ /*as_valid_symlink=*/true)
+ .has_value();
});
};
@@ -138,7 +140,10 @@ auto GitTreeEntry::Blob() const noexcept -> std::optional<std::string> {
if (not IsBlob()) {
return std::nullopt;
}
- return cas_->ReadObject(raw_id_, /*is_hex_id=*/false);
+ // return only valid blobs
+ return cas_->ReadObject(raw_id_,
+ /*is_hex_id=*/false,
+ /*as_valid_symlink=*/IsSymlinkObject(type_));
}
auto GitTreeEntry::Tree(bool ignore_special) const& noexcept