Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tweaked some formatting.
[rsync/rsync.git]
/
main.c
diff --git
a/main.c
b/main.c
index
d6eb8d8
..
75070e3
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-219,7
+219,7
@@
static pid_t do_cmd(char *cmd, char *machine, char *user, char *path,
int *f_in, int *f_out)
{
int i, argc = 0;
int *f_in, int *f_out)
{
int i, argc = 0;
- char *args[
100
];
+ char *args[
MAX_ARGS
];
pid_t ret;
char *tok, *dir = NULL;
int dash_l_set = 0;
pid_t ret;
char *tok, *dir = NULL;
int dash_l_set = 0;
@@
-234,8
+234,14
@@
static pid_t do_cmd(char *cmd, char *machine, char *user, char *path,
if (!cmd)
goto oom;
if (!cmd)
goto oom;
- for (tok = strtok(cmd, " "); tok; tok = strtok(NULL, " "))
+ for (tok = strtok(cmd, " "); tok; tok = strtok(NULL, " ")) {
+ /* 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;
args[argc++] = tok;
+ }
/* check to see if we've already been given '-l user' in
* the remote-shell command */
/* check to see if we've already been given '-l user' in
* the remote-shell command */
@@
-272,6
+278,11
@@
static pid_t do_cmd(char *cmd, char *machine, char *user, char *path,
}
server_options(args,&argc);
}
server_options(args,&argc);
+
+ if (argc >= MAX_ARGS - 2) {
+ rprintf(FERROR, "internal: args[] overflowed in do_cmd()\n");
+ exit_cleanup(RERR_SYNTAX);
+ }
}
args[argc++] = ".";
}
args[argc++] = ".";
@@
-279,16
+290,11
@@
static pid_t do_cmd(char *cmd, char *machine, char *user, char *path,
if (!daemon_over_rsh && path && *path)
args[argc++] = path;
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=");
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");
}
rprintf(FINFO,"%s ",args[i]);
rprintf(FINFO,"\n");
}
@@
-390,12
+396,12
@@
static void do_server_sender(int f_in, int f_out, int argc,char *argv[])
int l = strlen(dir);
if (strcmp(dir,"/") == 0)
l = 0;
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) {
argv[i] += l+1;
}
if (argc == 0 && recurse) {
- argc
=
1;
+ argc
=
1;
argv--;
argv[0] = ".";
}
argv--;
argv[0] = ".";
}
@@
-422,7
+428,7
@@
static void do_server_sender(int f_in, int f_out, int argc,char *argv[])
static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
{
int pid;
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)
int error_pipe[2];
if (preserve_hard_links)
@@
-442,7
+448,7
@@
static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
io_flush(NORMAL_FLUSH);
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);
close(error_pipe[0]);
if (f_in != f_out)
close(f_out);