From f66db4bb21efeead140a453f91280bb9471f24a9 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Fri, 17 Nov 2023 13:01:28 +0100 Subject: built-in "install" rule: verify well-formedness of resulting stage The install target, like any other target, has to have artifacts and runfiles being proper stages, i.e., in such a way that the keys can be interpreted as names in the file system without causing conflicts. This property used to be unchecked, thus allowing users to define mal-formed targets that, when used as inputs to actions, would result in unspecified layout of the action directory. Fix this by adding an appropriate check enforcing well-formedness of the resulting stage. --- src/buildtool/build_engine/target_map/built_in_rules.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/buildtool/build_engine/target_map/built_in_rules.cpp b/src/buildtool/build_engine/target_map/built_in_rules.cpp index 6bd65a55..70ecf1f2 100644 --- a/src/buildtool/build_engine/target_map/built_in_rules.cpp +++ b/src/buildtool/build_engine/target_map/built_in_rules.cpp @@ -666,6 +666,11 @@ void InstallRuleWithDeps( stage = ExpressionPtr{Expression::map_t{stage, to_stage}}; } + auto conflict = BuildMaps::Target::Utils::tree_conflict(stage); + if (conflict) { + (*logger)(fmt::format("TREE conflict on subtree {}", *conflict), true); + return; + } auto const& empty_map = Expression::kEmptyMap; auto result = std::make_shared( TargetResult{ -- cgit v1.2.3