]> granicus.if.org Git - icinga2/commitdiff
Fixed PATH_MAX problems on *NIX.
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 2 Apr 2012 17:38:04 +0000 (19:38 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 2 Apr 2012 17:38:58 +0000 (19:38 +0200)
base/application.cpp
base/unix.h

index 1a5c9ddc3773e1d276010b2621fdf16f88a83494..38be79113e411d287d5a1a37dd1b511c8d07fd97 100644 (file)
@@ -274,8 +274,8 @@ string Application::GetExeDirectory(void)
                return ExePath;
 
 #ifndef _WIN32
-       char Buf[MAXPATHLEN], Cwd[MAXPATHLEN];
-       char *PathEnv, *Directory, PathTest[MAXPATHLEN], FullExePath[MAXPATHLEN];
+       char Cwd[MAXPATHLEN];
+       char *Buf, *PathEnv, *Directory, PathTest[MAXPATHLEN], FullExePath[MAXPATHLEN];
        bool FoundPath;
 
        const char *argv0 = m_Arguments[0].c_str();
@@ -319,7 +319,7 @@ string Application::GetExeDirectory(void)
                }
        }
 
-       if (realpath(FullExePath, Buf) == NULL)
+       if ((Buf = realpath(FullExePath, NULL)) == NULL)
                throw exception(/*"realpath() failed"*/);
 
        // remove filename
@@ -329,6 +329,8 @@ string Application::GetExeDirectory(void)
                *LastSlash = '\0';
 
        ExePath = string(Buf);
+
+       free(Buf);
 #else /* _WIN32 */
        char FullExePath[MAXPATHLEN];
 
index 9876ab5cffba09ab7bd7da853817758de0d224ff..ea946f348dab8fb9cc1ca0428c0a27bf82b7e7ab 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef UNIX_H
 #define UNIX_H
 
+#include <limits.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -19,10 +20,6 @@ void closesocket(SOCKET fd);
 
 #define ioctlsocket ioctl
 
-#ifndef PATH_MAX
-#      define PATH_MAX 1024
-#endif /* PATH_MAX */
-
 #define MAXPATHLEN PATH_MAX
 
 /* default visibility takes care of exported symbols */