summaryrefslogtreecommitdiffstats
path: root/commands/cp.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-04-19 10:00:03 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-04-19 10:00:11 +0200
commit7418bf8e11ce2cecc78feef1c13eafd9cb429137 (patch)
treee37eea53be880fbe8d9c483f04e06fb52ace029f /commands/cp.c
parentf90427b5d2710bacdce2e81ef235db4b146edecc (diff)
downloadbarebox-7418bf8e11ce2cecc78feef1c13eafd9cb429137.tar.gz
barebox-7418bf8e11ce2cecc78feef1c13eafd9cb429137.tar.xz
cp: Use posix_basename() on source argument
The GNU basename version does not work with strings which have a trailing slash. Use posix_basename instead. With this cp -r can properly work on source arguments which have a trailing slash, i.e. "cp /dir1/ dst". Reported-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/cp.c')
-rw-r--r--commands/cp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/commands/cp.c b/commands/cp.c
index 4f1c068dd6..54934dd64f 100644
--- a/commands/cp.c
+++ b/commands/cp.c
@@ -76,7 +76,8 @@ static int do_cp(int argc, char *argv[])
for (i = optind; i < argc - 1; i++) {
char *dst;
- dst = concat_path_file(argv[argc - 1], basename(argv[i]));
+
+ dst = concat_path_file(argv[argc - 1], posix_basename(argv[i]));
if (recursive)
ret = copy_recursive(argv[i], dst);