diff options
author | Kurtis Rader <krader@skepticism.us> | 2016-04-13 09:00:07 -0700 |
---|---|---|
committer | Kurtis Rader <krader@skepticism.us> | 2016-04-13 09:00:07 -0700 |
commit | ea3d9c36a52dcf6bcde0ff41af8ca19daca2267e (patch) | |
tree | 5ef5e294b34de040fecce1d549aa6191022c1879 /src/fish.cpp | |
parent | 706bfa70c144775126e15a960028d3b3df7980fb (diff) |
fix off by one error
Diffstat (limited to 'src/fish.cpp')
-rw-r--r-- | src/fish.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/fish.cpp b/src/fish.cpp index bde7854e..9676814d 100644 --- a/src/fish.cpp +++ b/src/fish.cpp @@ -62,9 +62,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include "input_common.h" #include "wildcard.h" -/* PATH_MAX may not exist */ +// PATH_MAX may not exist. #ifndef PATH_MAX -#define PATH_MAX 1024 +#define PATH_MAX 4096 #endif /* If we are doing profiling, the filename to output to */ @@ -95,7 +95,7 @@ extern "C" { // Return the path to the current executable. This needs to be realpath'd. static std::string get_executable_path(const char *argv0) { - char buff[PATH_MAX + 1]; + char buff[PATH_MAX]; #if __APPLE__ // On OS X use it's proprietary API to get the path to the executable. @@ -104,11 +104,11 @@ static std::string get_executable_path(const char *argv0) #else // On non-OS X UNIXes, try /proc directory. ssize_t len; - len = readlink("/proc/self/exe", buff, sizeof buff); // Linux + len = readlink("/proc/self/exe", buff, sizeof buff - 1); // Linux if (len == -1) { - len = readlink("/proc/curproc/file", buff, sizeof buff); // BSD + len = readlink("/proc/curproc/file", buff, sizeof buff - 1); // BSD if (len == -1) { - len = readlink("/proc/self/path/a.out", buff, sizeof buff); // Solaris + len = readlink("/proc/self/path/a.out", buff, sizeof buff - 1); // Solaris } } if (len > 0) { |