Handle relative symlink targets robustly in cache tar logic

This commit is contained in:
copilot-swe-agent[bot] 2026-06-13 23:54:29 +00:00 committed by GitHub
parent ccaf722e7c
commit 3519ec1fc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -106,7 +106,7 @@ for installed_package in ${installed_packages}; do
get_tar_relpath "${f}"
if [ -L "${f}" ]; then
symlink_path="${f}"
# Guard against circular links while still supporting deep alternatives chains.
# Guard against circular links; 40 is intentionally high for alternatives chains.
max_symlink_depth=40
for i in $(seq 1 ${max_symlink_depth}); do
if [ ! -L "${symlink_path}" ]; then
@ -119,7 +119,12 @@ for installed_package in ${installed_packages}; do
target_path="${target}"
;;
*)
target_path="$(dirname "${symlink_path}")/${target}"
target_dir="$(dirname "${symlink_path}")"
if [ "${target_dir}" = "/" ]; then
target_path="/${target}"
else
target_path="${target_dir}/${target}"
fi
;;
esac