extern int recurse;
extern int relative_paths;
extern int rsync_port;
+extern int whole_file;
extern int read_batch;
extern int write_batch;
extern int filesfrom_fd;
goto oom;
for (tok = strtok(cmd, " "); tok; tok = strtok(NULL, " ")) {
- if (argc >= MAX_ARGS) {
- rprintf(FERROR, "Command is too long\n");
+ /* Comparison leaves rooms for server_options(). */
+ if (argc >= MAX_ARGS - 100) {
+ rprintf(FERROR, "internal: args[] overflowed in do_cmd()\n");
exit_cleanup(RERR_SYNTAX);
}
args[argc++] = tok;
}
server_options(args,&argc);
+
+ if (argc >= MAX_ARGS - 2) {
+ rprintf(FERROR, "internal: args[] overflowed in do_cmd()\n");
+ exit_cleanup(RERR_SYNTAX);
+ }
}
args[argc++] = ".";
if (!daemon_over_rsh && path && *path)
args[argc++] = path;
- if (argc >= (int)(sizeof args / sizeof args[0])) {
- rprintf(FERROR, "internal: args[] overflowed in do_cmd()\n");
- exit_cleanup(RERR_MALLOC); /* XXX Need better RERR? */
- }
-
args[argc] = NULL;
if (verbose > 3) {
rprintf(FINFO,"cmd=");
- for (i=0;i<argc;i++)
+ for (i = 0; i < argc; i++)
rprintf(FINFO,"%s ",args[i]);
rprintf(FINFO,"\n");
}
if (local_server) {
if (read_batch)
create_flist_from_batch(); /* sets batch_flist */
+ /* If the user didn't request --[no-]whole-file, force
+ * it on, but only if we're not batch processing. */
+ if (whole_file < 0 && !read_batch && !write_batch)
+ whole_file = 1;
ret = local_child(argc, args, f_in, f_out, child_main);
} else {
ret = piped_child(args,f_in,f_out);
int l = strlen(dir);
if (strcmp(dir,"/") == 0)
l = 0;
- for (i=0;i<argc;i++)
+ for (i = 0; i < argc; i++)
argv[i] += l+1;
}
if (argc == 0 && recurse) {
- argc=1;
+ argc = 1;
argv--;
argv[0] = ".";
}
static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
{
int pid;
- int status=0;
+ int status = 0;
int error_pipe[2];
if (preserve_hard_links)
io_flush(NORMAL_FLUSH);
- if ((pid=do_fork()) == 0) {
+ if ((pid = do_fork()) == 0) {
close(error_pipe[0]);
if (f_in != f_out)
close(f_out);