aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-04-13 09:00:07 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-04-15 15:17:57 -0700
commitd7fd0427f36c5cb761bd61875d44d58329156660 (patch)
treefca00fa5f4c5775a161f0c16d4bada1dcca0f5b8 /src
parentbaee8078377109bec778b77b061a56d240c34eb5 (diff)
fix off by one error
(cherry picked from commit ea3d9c36a52dcf6bcde0ff41af8ca19daca2267e)
Diffstat (limited to 'src')
-rw-r--r--src/fish.cpp12
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) {