From 0350f95e7bfd0fc6c444682f16e0c9af32874eac Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sun, 29 Oct 2017 15:22:22 -0700 Subject: [PATCH] Add an extra argc validation in do_server_sender(). Fixes bug 13104. --- main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 3908ccf5..ec896670 100644 --- a/main.c +++ b/main.c @@ -783,7 +783,7 @@ static void read_final_goodbye(int f_in, int f_out) static void do_server_sender(int f_in, int f_out, int argc, char *argv[]) { struct file_list *flist; - char *dir = argv[0]; + char *dir; if (DEBUG_GTE(SEND, 1)) rprintf(FINFO, "server_sender starting pid=%d\n", (int)getpid()); @@ -791,16 +791,19 @@ static void do_server_sender(int f_in, int f_out, int argc, char *argv[]) if (am_daemon && lp_write_only(module_id)) { rprintf(FERROR, "ERROR: module is write only\n"); exit_cleanup(RERR_SYNTAX); - return; } if (am_daemon && read_only && remove_source_files) { rprintf(FERROR, - "ERROR: --remove-%s-files cannot be used with a read-only module\n", - remove_source_files == 1 ? "source" : "sent"); + "ERROR: --remove-%s-files cannot be used with a read-only module\n", + remove_source_files == 1 ? "source" : "sent"); + exit_cleanup(RERR_SYNTAX); + } + if (argc < 1) { + rprintf(FERROR, "ERROR: do_server_sender called without args\n"); exit_cleanup(RERR_SYNTAX); - return; } + dir = argv[0]; if (!relative_paths) { if (!change_dir(dir, CD_NORMAL)) { rsyserr(FERROR, errno, "change_dir#3 %s failed", -- 2.47.2