summaryrefslogtreecommitdiffstats
path: root/main/xulrunner/fix-xulrunner-launcher.patch
blob: 62af1ab3087a497b5614ed514150b8f116656a59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
--- a/xulrunner/stub/nsXULStub.cpp	2008-07-17 21:43:11.000000000 +0200
+++ b/xulrunner/stub/nsXULStub.cpp	2008-07-17 21:47:04.000000000 +0200
@@ -208,8 +208,10 @@
   // 3) give up
 
   struct stat fileStat;
+  char *testp;
 
-  if (!realpath(argv[0], iniPath) || stat(iniPath, &fileStat)) {
+  testp = realpath(argv[0], iniPath);
+  if (!(testp != NULL && stat(iniPath, &fileStat) == 0 && S_ISREG(fileStat.st_mode) && fileStat.st_mode & S_IXUSR) || (testp != NULL && stat(iniPath, &fileStat))) {
     const char *path = getenv("PATH");
     if (!path)
       return 1;
@@ -222,7 +224,7 @@
     char *token = strtok(pathdup, ":");
     while (token) {
       sprintf(tmpPath, "%s/%s", token, argv[0]);
-      if (realpath(tmpPath, iniPath) && stat(iniPath, &fileStat) == 0) {
+      if (realpath(tmpPath, iniPath) && stat(iniPath, &fileStat) == 0 && S_ISREG(fileStat.st_mode) && fileStat.st_mode & S_IXUSR) {
         found = PR_TRUE;
         break;
       }