summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/initfile.cc
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2009-10-02 16:59:12 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2009-10-02 17:00:39 +0530
commitff237f26c6e3a09ab373b16822b463235f2aef86 (patch)
tree715449b8cf1f3b8c8997abd2bbda6f9d997fbd17 /crawl-ref/source/initfile.cc
parentd7f62c71f7072f27c177a2de181fd8dc68d427d8 (diff)
downloadcrawl-ref-ff237f26c6e3a09ab373b16822b463235f2aef86.tar.gz
crawl-ref-ff237f26c6e3a09ab373b16822b463235f2aef86.zip
readlink does not NULL-terminate, must terminate explicitly.
Diffstat (limited to 'crawl-ref/source/initfile.cc')
-rw-r--r--crawl-ref/source/initfile.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 5ea6dc449c..7d7e9f033c 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -3459,7 +3459,10 @@ std::string find_executable_path()
#if defined ( _MSC_VER )
GetModuleFileName ( NULL, tempPath, sizeof(tempPath) );
#elif defined ( __linux__ )
- readlink ( "/proc/self/exe", tempPath, sizeof(tempPath) );
+ const ssize_t rsize =
+ readlink("/proc/self/exe", tempPath, sizeof(tempPath) - 1);
+ if (rsize > 0)
+ tempPath[rsize] = 0;
#elif defined ( __MACH__ )
strncpy ( tempPath, NXArgv[0], sizeof(tempPath) );
#else