Properly support running programs using relative pathnames.

Previously, relative pathnames other than those starting with "." or ".." wouldn't be recognized.
This commit is contained in:
Stephen Heumann 2015-02-03 21:24:10 -06:00
parent ad96f52394
commit 0d0ec552b5
1 changed files with 20 additions and 15 deletions

View File

@ -181,7 +181,6 @@ int execve(const char *path, char *const *argv, char *const *envp)
fileInfoRec.pCount = 4;
fileInfoRec.pathname = path_gs;
GetFileInfoGS(&fileInfoRec);
/* If it's not an EXEC file, error out. */
if (toolerror()) {
errno = ENOENT;
goto error_ret;
@ -200,7 +199,7 @@ int execve(const char *path, char *const *argv, char *const *envp)
args = NULL;
/* If _execve kernel call failed, consider trying to execute
* the file as a script. */
* the file as a script. If it's not an EXEC file, error out. */
if (fileInfoRec.fileType != 0xB0 || fileInfoRec.auxType != 0x0006) {
errno = EACCES;
goto error_ret;
@ -295,6 +294,7 @@ int execvp(const char *file, char *const *argv)
int result;
char *path, *path2;
if (!strpbrk(file, "/:")) {
path = buildPath(file);
if (path == NULL) {
errno = ENOENT;
@ -310,11 +310,16 @@ int execvp(const char *file, char *const *argv)
}
strcpy(path2, path);
free(path);
} else {
path2 = (char *)file;
}
result = execve(path2, argv, environ);
/* error case */
if (path2 != file) {
dealloc_for_current_process(path2);
}
return result;
}
#endif