This is an automated email from the ASF dual-hosted git repository. juergbi pushed a commit to branch jbilleter/checkout in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 79de5cf1cbf7ca009cd4ec0e81fc3e06282d45f7 Author: Jürg Billeter <[email protected]> AuthorDate: Fri Oct 2 10:30:39 2026 +0200 utils.py: Fix `_ensure_real_directory()` `os.path.split()` splits the path into a `(head, tail)` pair, not into a list of all path segments. Use `pathlib` to iterate over all path segments and also reject absolute paths. `_ensure_real_directory()` is only called from `_process_list()`, though, where it's separately called for each level in the hierarchy. Due to this, it seems each path segment was already checked and thus, the previous bug didn't cause any issues. --- src/buildstream/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/buildstream/utils.py b/src/buildstream/utils.py index 8673813dc..09cb6b2bd 100644 --- a/src/buildstream/utils.py +++ b/src/buildstream/utils.py @@ -34,7 +34,7 @@ import tempfile import threading import itertools from contextlib import contextmanager -from pathlib import Path +from pathlib import Path, PurePath from typing import Callable, IO, Iterable, Iterator, Optional, Tuple, Union, Pattern from google.protobuf import timestamp_pb2 @@ -1064,7 +1064,10 @@ def _copy_directories(srcdir, destdir, target): # def _ensure_real_directory(root, path): destpath = root - for name in os.path.split(path): + purepath = PurePath(path) + if purepath.is_absolute(): + raise UtilError(f"Expected relative path, got absolute path: {path}") + for name in purepath.parts: destpath = os.path.join(destpath, name) try: deststat = os.lstat(destpath)
