Subversion Repositories HelenOS

Rev

Rev 4112 | Rev 4266 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4112 Rev 4264
Line 69... Line 69...
69
static char *find_command(char *cmd)
69
static char *find_command(char *cmd)
70
{
70
{
71
    char *path_tok;
71
    char *path_tok;
72
    char *path[PATH_MAX];
72
    char *path[PATH_MAX];
73
    int n = 0, i = 0;
73
    int n = 0, i = 0;
74
    size_t x = strlen(cmd) + 2;
74
    size_t x = str_size(cmd) + 2;
75
 
75
 
76
    found = (char *)malloc(PATH_MAX);
76
    found = (char *)malloc(PATH_MAX);
77
 
77
 
78
    /* The user has specified a full or relative path, just give it back. */
78
    /* The user has specified a full or relative path, just give it back. */
79
    if (-1 != try_access(cmd)) {
79
    if (-1 != try_access(cmd)) {
Line 83... Line 83...
83
    path_tok = strdup(PATH);
83
    path_tok = strdup(PATH);
84
 
84
 
85
    /* Extract the PATH env to a path[] array */
85
    /* Extract the PATH env to a path[] array */
86
    path[n] = strtok(path_tok, PATH_DELIM);
86
    path[n] = strtok(path_tok, PATH_DELIM);
87
    while (NULL != path[n]) {
87
    while (NULL != path[n]) {
88
        if ((strlen(path[n]) + x ) > PATH_MAX) {
88
        if ((str_size(path[n]) + x ) > PATH_MAX) {
89
            cli_error(CL_ENOTSUP,
89
            cli_error(CL_ENOTSUP,
90
                "Segment %d of path is too large, search ends at segment %d",
90
                "Segment %d of path is too large, search ends at segment %d",
91
                n, n-1);
91
                n, n-1);
92
            break;
92
            break;
93
        }
93
        }