Bug 325471 Broken search for path to binary on linux in xulrunner-stub

patch by prefiks@aviary.pl r=bsmedberg
This commit is contained in:
timeless%mozdev.org 2006-02-02 17:23:26 +00:00
parent 7c51177559
commit 0fb88d98ce
2 changed files with 7 additions and 4 deletions

View File

@ -1078,6 +1078,7 @@ XRE_GetBinaryPath(const char* argv0, nsILocalFile* *aResult)
#elif defined(XP_UNIX)
struct stat fileStat;
char exePath[MAXPATHLEN];
char tmpPath[MAXPATHLEN];
rv = NS_ERROR_FAILURE;
@ -1120,8 +1121,8 @@ XRE_GetBinaryPath(const char* argv0, nsILocalFile* *aResult)
char *newStr = pathdup;
char *token;
while ( (token = nsCRT::strtok(newStr, ":", &newStr)) ) {
sprintf(exePath, "%s/%s", token, argv0);
if (stat(exePath, &fileStat) == 0) {
sprintf(tmpPath, "%s/%s", token, argv0);
if (realpath(tmpPath, exePath) && stat(exePath, &fileStat) == 0) {
found = PR_TRUE;
break;
}

View File

@ -66,6 +66,7 @@ main(int argc, char **argv)
char *lastSlash;
char iniPath[MAXPATHLEN];
char tmpPath[MAXPATHLEN];
#ifdef XP_WIN
if (!::GetModuleFileName(NULL, iniPath, sizeof(iniPath)))
@ -96,11 +97,12 @@ main(int argc, char **argv)
PRBool found = PR_FALSE;
char *token = strtok(pathdup, ":");
while (token) {
sprintf(iniPath, "%s/%s", token, argv[0]);
if (stat(iniPath, &fileStat) == 0) {
sprintf(tmpPath, "%s/%s", token, argv[0]);
if (realpath(tmpPath, iniPath) && stat(iniPath, &fileStat) == 0) {
found = PR_TRUE;
break;
}
token = strtok(NULL, ":");
}
free (pathdup);
if (!found)