You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:13:44 UTC
[buildstream] 23/43: Detect infinite symlink loops in resolve()
This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch jmac/cas_to_cas_oct_v2
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 5fc7d6b407edc3a4335144e4658f5e52a5ec13cd
Author: Jim MacArthur <ji...@codethink.co.uk>
AuthorDate: Thu Oct 25 16:48:07 2018 +0100
Detect infinite symlink loops in resolve()
---
buildstream/storage/_casbaseddirectory.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/buildstream/storage/_casbaseddirectory.py b/buildstream/storage/_casbaseddirectory.py
index 3388cfc..ce0ec2b 100644
--- a/buildstream/storage/_casbaseddirectory.py
+++ b/buildstream/storage/_casbaseddirectory.py
@@ -388,7 +388,7 @@ class CasBasedDirectory(Directory):
return directory
- def _resolve(self, name, absolute_symlinks_resolve=True, force_create=False):
+ def _resolve(self, name, absolute_symlinks_resolve=True, force_create=False, first_seen_object = None):
""" Resolves any name to an object. If the name points to a symlink in
this directory, it returns the thing it points to,
recursively. Returns a CasBasedDirectory, FileNode or
@@ -407,6 +407,14 @@ class CasBasedDirectory(Directory):
return index_entry.pb_object
assert isinstance(index_entry.pb_object, remote_execution_pb2.SymlinkNode)
+
+ if first_seen_object is None:
+ first_seen_object = index_entry.pb_object
+ else:
+ if index_entry.pb_object == first_seen_object:
+ ### Infinite symlink loop detected ###
+ return None
+
print("Resolving '{}': This is a symlink node in the current directory.".format(name))
symlink = index_entry.pb_object
components = symlink.target.split(CasBasedDirectory._pb2_path_sep)
@@ -440,7 +448,7 @@ class CasBasedDirectory(Directory):
directory = directory.parent
else:
if c in directory.index:
- f = directory._resolve(c, absolute_symlinks_resolve)
+ f = directory._resolve(c, absolute_symlinks_resolve, first_seen_object=first_seen_object)
# Ultimately f must now be a file or directory
if isinstance(f, CasBasedDirectory):
directory = f