Merge pull request #15828 from carlocab/recursive-rpaths

os/mac/mach: avoid recursively resolving rpaths
This commit is contained in:
Carlo Cabrera 2023-08-05 23:58:07 +08:00 committed by GitHub
commit 3eb48a828d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,17 +97,18 @@ module MachOShim
def rpaths(resolve_variable_references: true)
names = macho.rpaths
names.map!(&method(:resolve_variable_name)) if resolve_variable_references
# Don't recursively resolve rpaths to avoid infinite loops.
names.map! { |name| resolve_variable_name(name, resolve_rpaths: false) } if resolve_variable_references
names
end
def resolve_variable_name(name)
def resolve_variable_name(name, resolve_rpaths: true)
if name.start_with? "@loader_path"
Pathname(name.sub("@loader_path", dirname)).cleanpath.to_s
elsif name.start_with?("@executable_path") && binary_executable?
Pathname(name.sub("@executable_path", dirname)).cleanpath.to_s
elsif name.start_with?("@rpath") && (target = resolve_rpath(name)).present?
elsif resolve_rpaths && name.start_with?("@rpath") && (target = resolve_rpath(name)).present?
target
else
name