71,7 → 71,7 |
char *path_tok; |
char *path[PATH_MAX]; |
int n = 0, i = 0; |
size_t x = strlen(cmd) + 2; |
size_t x = str_size(cmd) + 2; |
|
found = (char *)malloc(PATH_MAX); |
|
80,18 → 80,18 |
return (char *) cmd; |
} |
|
path_tok = cli_strdup(PATH); |
path_tok = str_dup(PATH); |
|
/* Extract the PATH env to a path[] array */ |
path[n] = cli_strtok(path_tok, PATH_DELIM); |
path[n] = strtok(path_tok, PATH_DELIM); |
while (NULL != path[n]) { |
if ((strlen(path[n]) + x ) > PATH_MAX) { |
if ((str_size(path[n]) + x ) > PATH_MAX) { |
cli_error(CL_ENOTSUP, |
"Segment %d of path is too large, search ends at segment %d", |
n, n-1); |
break; |
} |
path[++n] = cli_strtok(NULL, PATH_DELIM); |
path[++n] = strtok(NULL, PATH_DELIM); |
} |
|
/* We now have n places to look for the command */ |
114,7 → 114,7 |
task_id_t tid; |
char *tmp; |
|
tmp = cli_strdup(find_command(cmd)); |
tmp = str_dup(find_command(cmd)); |
free(found); |
|
tid = task_spawn((const char *)tmp, argv); |
121,7 → 121,7 |
free(tmp); |
|
if (tid == 0) { |
cli_error(CL_EEXEC, "Can not spawn %s", cmd); |
cli_error(CL_EEXEC, "Cannot spawn `%s'.", cmd); |
return 1; |
} else { |
return 0; |