Reported by @HackingRepo via security advisory GHSA-x6wh-gw25-4rjx. We don't consider this a security issue, so we're tracking it as a regular bug.
Description
cp fails to create a backup in two cases where GNU does, risking silent loss of the overwritten file's previous contents.
Repro
$ echo data > a; echo dest > b
$ cp --backup=nil --suffix= a b # uu: no b~ created
$ cp --backup --suffix= a b # uu: no b~ created
GNU creates b~ in both cases (nil is the existing backup control, and --backup with an empty --suffix falls back to the default ~).
Expected: a backup b~ is created before b is overwritten.
Actual: no backup; previous contents of b are lost.
Follow-up to the earlier --suffix-alone backup fix; the same guard is still bypassable via --backup=nil and an empty suffix. A test should cover both forms.
Reported by @HackingRepo via security advisory GHSA-x6wh-gw25-4rjx. We don't consider this a security issue, so we're tracking it as a regular bug.
Description
cpfails to create a backup in two cases where GNU does, risking silent loss of the overwritten file's previous contents.Repro
GNU creates
b~in both cases (nilis the existing backup control, and--backupwith an empty--suffixfalls back to the default~).Expected: a backup
b~is created beforebis overwritten.Actual: no backup; previous contents of
bare lost.Follow-up to the earlier
--suffix-alone backup fix; the same guard is still bypassable via--backup=niland an empty suffix. A test should cover both forms.