Skip to content

Commit

Permalink
Complain if the destination arg is empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
WayneD committed Oct 2, 2022
1 parent fdf5e57 commit 25efa10
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,16 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
return pid;
}

/* Older versions turn an empty string as a reference to the current directory.
* We now treat this as an error unless --old-args was used. */
static char *dot_dir_or_error()
{
if (old_style_args || am_server)
return ".";
rprintf(FERROR, "Empty destination arg specified (use \".\" or see --old-args).\n");
exit_cleanup(RERR_SYNTAX);
}

/* The receiving side operates in one of two modes:
*
* 1. it receives any number of files into a destination directory,
Expand Down Expand Up @@ -687,9 +697,8 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
if (!dest_path || list_only)
return NULL;

/* Treat an empty string as a copy into the current directory. */
if (!*dest_path)
dest_path = ".";
dest_path = dot_dir_or_error();

if (daemon_filter_list.head) {
char *slash = strrchr(dest_path, '/');
Expand Down Expand Up @@ -1432,6 +1441,8 @@ static int start_client(int argc, char *argv[])

if (argc > 1) {
p = argv[--argc];
if (!*p)
p = dot_dir_or_error();
remote_argv = argv + argc;
} else {
static char *dotarg[1] = { "." };
Expand Down

0 comments on commit 25efa10

Please sign in to comment.