summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-06-13 17:35:05 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-06-26 17:57:29 +0200
commitc11e9142d2a1b04004dcbed282dc1e04d116e03f (patch)
treeb1c72fa8f9491f35b3c631ce98acbf00e627a59d /src/buildtool/execution_api
parentd2e3ad946b35a72a94b2d125550daf5d5e4c9904 (diff)
downloadjustbuild-c11e9142d2a1b04004dcbed282dc1e04d116e03f.tar.gz
ReadTree: Add check for non-upwards symlinks...
...as early as possible. This ensures that callers always receive only the tree entries for the supported object types. For the symlinks non-upwardness check we pass a lambda capturing the real backend of the tree entries, such that the symlinks can be read. Updates git_tree tests accordingly.
Diffstat (limited to 'src/buildtool/execution_api')
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp
index 159a848e..60ed22e1 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp
@@ -42,9 +42,32 @@ namespace {
auto blobs = network->ReadBlobs({digest}).Next();
if (blobs.size() == 1) {
auto const& content = blobs.at(0).data;
+ auto check_symlinks =
+ [&network](std::vector<bazel_re::Digest> const& ids) {
+ auto size = ids.size();
+ auto reader = network->ReadBlobs(ids);
+ auto blobs = reader.Next();
+ std::size_t count{};
+ while (not blobs.empty()) {
+ if (count + blobs.size() > size) {
+ Logger::Log(LogLevel::Debug,
+ "received more blobs than requested.");
+ return false;
+ }
+ for (auto const& blob : blobs) {
+ if (not PathIsNonUpwards(blob.data)) {
+ return false;
+ }
+ }
+ count += blobs.size();
+ blobs = reader.Next();
+ }
+ return true;
+ };
return GitRepo::ReadTreeData(
content,
HashFunction::ComputeTreeHash(content).Bytes(),
+ check_symlinks,
/*is_hex_id=*/false);
}
Logger::Log(LogLevel::Error,