Fix off-by-one buffer overrun in get_exe_dir

Found by coverity
This commit is contained in:
Alexander van Gessel 2013-12-02 17:00:46 +01:00
parent b2f5b44b19
commit 855d8116d1

View file

@ -455,7 +455,7 @@ std::string get_exe_dir()
{
#ifndef _WIN32
char buf[1024];
size_t path_size = readlink("/proc/self/exe", buf, 1024);
size_t path_size = readlink("/proc/self/exe", buf, sizeof(buf)-1);
if(path_size == static_cast<size_t>(-1))
return std::string();
buf[path_size] = 0;