Skip to content

cp: do not descend into a destination subdirectory that is a symlink - #13624

Open
sylvestre wants to merge 2 commits into
uutils:mainfrom
sylvestre:cp-dest-subdir-symlink
Open

cp: do not descend into a destination subdirectory that is a symlink#13624
sylvestre wants to merge 2 commits into
uutils:mainfrom
sylvestre:cp-dest-subdir-symlink

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

copy_direntry tested the destination with exists(), which resolves symlinks, so a destination entry that was itself a symlink to a directory looked like an existing directory and was descended into, writing the source subtree through the link and out of the destination tree. GNU refuses this.

Treat a symlink at the destination as the non-directory it is. A symlinked directory named as the target itself stays allowed.

copy_direntry tested the destination with exists(), which resolves symlinks, so
a destination entry that was itself a symlink to a directory looked like an
existing directory and was descended into, writing the source subtree through
the link and out of the destination tree. GNU refuses this.

Treat a symlink at the destination as the non-directory it is. A symlinked
directory named as the target itself stays allowed.
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/retry (passes in this run but fails in the 'main' branch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant