diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2017-04-19 10:00:03 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-04-19 10:00:11 +0200 |
commit | 7418bf8e11ce2cecc78feef1c13eafd9cb429137 (patch) | |
tree | e37eea53be880fbe8d9c483f04e06fb52ace029f /commands/cp.c | |
parent | f90427b5d2710bacdce2e81ef235db4b146edecc (diff) | |
download | barebox-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.c | 3 |
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); |