diff --git a/library/unistd_execve.c b/library/unistd_execve.c index 1d288dc..308f190 100644 --- a/library/unistd_execve.c +++ b/library/unistd_execve.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_execve.c,v 1.5 2006-08-02 11:07:57 obarthel Exp $ + * $Id: unistd_execve.c,v 1.6 2006-08-02 14:44:01 obarthel Exp $ * * :ts=4 * @@ -83,7 +83,7 @@ find_resident_command(const char * command_name) if(seg != NULL) { - /* Check if that's a disable command or something else. */ + /* Check if that's a disabled command or something else. */ if((seg->seg_UC < 0) && ((seg->seg_UC > CMD_INTERNAL) || (seg->seg_UC <= CMD_DISABLED))) { seg = NULL; @@ -149,8 +149,8 @@ get_first_script_line(const char * path,char ** line_ptr) script_line_size = script_line_length + 10; } - /* Stop when we hit a line feed or unprintable character */ - if(c == '\n' || c < ' ' || (c >= 128 && c < 160)) + /* Stop when we hit a line feed or an unprintable character */ + if(c == '\n' || (c < ' ' && c != '\t' && c != '\r') || (c >= 128 && c < 160)) break; script_line[script_line_length++] = c; @@ -594,7 +594,7 @@ build_arg_string(char *const argv[],char * arg_string) (*arg_string++) = '*'; (*arg_string++) = s[j]; } - else if(s[j] == '\n') + else if (s[j] == '\n') { (*arg_string++) = '*'; (*arg_string++) = 'N'; diff --git a/library/unistd_execvp.c b/library/unistd_execvp.c index 14091ea..580fd9a 100644 --- a/library/unistd_execvp.c +++ b/library/unistd_execvp.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_execvp.c,v 1.4 2006-08-02 08:00:29 obarthel Exp $ + * $Id: unistd_execvp.c,v 1.5 2006-08-02 14:44:01 obarthel Exp $ * * :ts=4 * @@ -96,8 +96,10 @@ int execvp(const char *command,char * const argv[]) { char * command_buffer = NULL; + size_t command_name_len,i; char * path_copy = NULL; int result = -1; + BOOL found_path_separators; /* Do not allow null command */ if(command == NULL || (*command) == '\0') @@ -106,14 +108,28 @@ execvp(const char *command,char * const argv[]) goto out; } + command_name_len = strlen(command); + + /* Check if there are any path separator characters in the + command name. */ + found_path_separators = FALSE; + + for(i = 0 ; i < command_name_len ; i++) + { + if(command[i] == '/' || command[i] == ':') + { + found_path_separators = TRUE; + break; + } + } + /* If it's an absolute or relative path name, it's easy. */ - if(strchr(command,'/') != NULL || strchr(command,':') != NULL) + if(found_path_separators) { result = execve(command, argv, environ); } else { - size_t command_name_len = strlen(command); size_t command_buffer_size = 0; char * path_delimiter; char * path;