From 350e4ef3bda5ab0c5f4ee02c21335c6967ad06ee Mon Sep 17 00:00:00 2001 From: "benjamin%smedbergs.us" Date: Wed, 22 Mar 2006 20:23:28 +0000 Subject: [PATCH] Bug 325471 - Broken search path to binary on linux in xulrunner-stub and firefox-bin - patch by Pawel Chmielowski (prefiks@aviary.pl) - r+a=me git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@192802 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/toolkit/xre/nsAppRunner.cpp | 5 +++-- mozilla/xulrunner/stub/nsXULStub.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mozilla/toolkit/xre/nsAppRunner.cpp b/mozilla/toolkit/xre/nsAppRunner.cpp index 8a49585b5f8..214e906567f 100644 --- a/mozilla/toolkit/xre/nsAppRunner.cpp +++ b/mozilla/toolkit/xre/nsAppRunner.cpp @@ -1075,6 +1075,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; @@ -1117,8 +1118,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; } diff --git a/mozilla/xulrunner/stub/nsXULStub.cpp b/mozilla/xulrunner/stub/nsXULStub.cpp index d5192fba36f..db02df93556 100644 --- a/mozilla/xulrunner/stub/nsXULStub.cpp +++ b/mozilla/xulrunner/stub/nsXULStub.cpp @@ -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)