Explorar o código

* Ported [2907] to 1.2.11
* Fixed problems with symlinked binaries. (fixes #240)


svn: 2908

Bryan Drewery %!s(int64=20) %!d(string=hai) anos
pai
achega
3493d93c07
Modificáronse 2 ficheiros con 8 adicións e 1 borrados
  1. 1 0
      doc/UPDATES
  2. 7 1
      src/main.c

+ 1 - 0
doc/UPDATES

@@ -10,6 +10,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Aliases may no longer reference other aliases (only checked when used) (fixes #244)
 * Fixed cmd_checkchannels so that results are not shown in log, but to user only. (fixes #217)
 * Disabled watcher feature.
+* Fixed problems with symlinked binaries. (fixes #240)
 
 1.2.10 - http://tracker.shatow.net/milestone/1.2.10
 * Removed old references to '+/-manop' and '+/-nomop' for chaninfo in help file.

+ 7 - 1
src/main.c

@@ -107,7 +107,7 @@ char *socksfile = NULL;
 static char *getfullbinname(const char *argv_zero)
 {
   char *bin = strdup(argv_zero), *p = NULL, *p2 = NULL;
-  char cwd[PATH_MAX] = "";
+  char cwd[PATH_MAX] = "", buf[PATH_MAX] = "";
 
   if (bin[0] == '/')
 #ifdef CYGWIN_HACKS
@@ -148,6 +148,12 @@ static char *getfullbinname(const char *argv_zero)
   strcat(bin, ".exe");
   bin[strlen(bin)] = 0;
 #endif /* CYGWIN_HACKS */
+  /* Fix for symlinked binaries */
+  realpath(bin, buf);
+  size_t len = strlen(buf);
+  bin = (char *) my_realloc(bin, len + 1);
+  strlcpy(bin, buf, len + 1);
+
   return bin;
 }