From e3f9b479cd43b5f7204403de83c8044523c4c432 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. (cherry picked from f66db4bb21efeead140a453f91280bb9471f24a9) --- CHANGELOG.md | 5 +++++ src/buildtool/build_engine/target_map/built_in_rules.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27c95c44..f0220b16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ Bug fixes on top of release `1.2.3`. +### Fixes + +- The built-in rule `"install"` now properly enforces that the + resulting stage is well-formed, i.e., without tree conflicts. + ## Release `1.2.3` (2023-11-15) Bug fixes on top of release `1.2.2`. 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 29eba7bf..6d55784f 100644 --- a/src/buildtool/build_engine/target_map/built_in_rules.cpp +++ b/src/buildtool/build_engine/target_map/built_in_rules.cpp @@ -665,6 +665,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