You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cp --remove-destination deletes the file when source and dest are the same #13144
Reported by @HackingRepo via security advisory GHSA-9p9p-xh9v-6fvx. We don't consider this a security issue, so we're tracking it as a regular bug.
Description cp --remove-destination a ./a removes the file before detecting that source and destination are the same path, destroying the data.
Repro
$ echo hello > a
$ cp --remove-destination a ./a
cp: cannot stat 'a': No such file or directory
$ cat a
cat: a: No such file or directory # file is gone
GNU refuses: cp: 'a' and './a' are the same file, leaving a intact.
Expected: detect the same-file case and error out without deleting. Actual: the file is unlinked, then the copy fails — data loss.
Activity
LoukasPap commentedon Jun 28, 2026
This is solved here: #13135
cakebaker commentedon Jul 1, 2026
@HackingRepo thanks for the hint!