summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2006-08-27 19:41:04 +0000
committerJim Meyering <jim@meyering.net>2006-08-27 19:41:04 +0000
commit520a954d7e8823a4c385c662b3b571ae53f125ea (patch)
treed62505143c782bebd736615f4d44a27db01e0694 /src
parent07446625096ddeb9246fb36572d5fe644f56cd1f (diff)
downloadcoreutils-520a954d7e8823a4c385c662b3b571ae53f125ea.tar.xz
* src/copy.c (copy_internal): Don't make a backup if the last
component of the source name is "." or "..". Reported by Andreas Schwab in https://savannah.gnu.org/bugs/?17540. * tests/cp/src-base-dot: New file. Test for the above fix. * tests/cp/Makefile.am (TESTS): Add src-base-dot.
Diffstat (limited to 'src')
-rw-r--r--src/copy.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/copy.c b/src/copy.c
index 5b69e8ad2..c8d09b4ee 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -1185,7 +1185,10 @@ copy_internal (char const *src_name, char const *dst_name,
}
}
- if (x->backup_type != no_backups)
+ if (x->backup_type != no_backups
+ /* Don't try to back up a destination if the last
+ component of src_name is "." or "..". */
+ && ! dot_or_dotdot (last_component (src_name)))
{
char *tmp_backup = find_backup_file_name (dst_name,
x->backup_type);