From a2b21f29edaa2c3448d6542870279d6217c43508 Mon Sep 17 00:00:00 2001 From: Illia Bobyr Date: Thu, 3 May 2018 16:38:40 -0700 Subject: [PATCH 1/2] cp: No dup check for unlink_dest_after_failed_open A case when unlink_dest_after_failed_open is set and the destination is a symbolic link is checked in same_file_ok() in lines 1565-1572. It does not make sense to check again. --- src/copy.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/copy.c b/src/copy.c index 4998c83e6..dbfabf215 100644 --- a/src/copy.c +++ b/src/copy.c @@ -1629,11 +1629,9 @@ same_file_ok (char const *src_name, struct stat const *src_sb, /* It's ok to remove a destination symlink. But that works only when creating symbolic links, or when the source and destination - are on the same file system and when creating hard links or when - unlinking before opening the destination. */ + are on the same file system and creating hard links. */ if (x->symbolic_link - || ((x->hard_link || x->unlink_dest_before_opening) - && S_ISLNK (dst_sb_link->st_mode))) + || (x->hard_link && S_ISLNK (dst_sb_link->st_mode))) return dst_sb_link->st_dev == src_sb_link->st_dev; if (x->dereference == DEREF_NEVER) -- 2.17.0.441.gb46fe60e1d-goog