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;
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;
+ }
/* check to see if we've already been given '-l user' in
* the remote-shell command */
}
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");
}
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;
}