From 026939f58dfd8e77a6b7d953fca365fe1ec9187a Mon Sep 17 00:00:00 2001 From: Spoike Date: Thu, 16 Jan 2014 07:03:40 +0000 Subject: [PATCH] readlink doesn't null terminate. oops. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4591 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/sys_linux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/client/sys_linux.c b/engine/client/sys_linux.c index c71a110fe..82ff09e54 100644 --- a/engine/client/sys_linux.c +++ b/engine/client/sys_linux.c @@ -764,9 +764,10 @@ int main (int c, const char **v) #endif parms.basedir = basedir; + memset(bindir, 0, sizeof(bindir)); //readlink does NOT null terminate, apparently. #ifdef __linux__ //attempt to figure out where the exe is located - if (readlink("/proc/self/exe", bindir, sizeof(bindir)) > 0) + if (readlink("/proc/self/exe", bindir, sizeof(bindir)-1) > 0) { *COM_SkipPath(bindir) = 0; printf("Binary is located at \"%s\"\n", bindir); @@ -774,7 +775,7 @@ int main (int c, const char **v) } /*#elif defined(__bsd__) //attempt to figure out where the exe is located - if (readlink("/proc/self/file", bindir, sizeof(bindir)) > 0) + if (readlink("/proc/self/file", bindir, sizeof(bindir)-1) > 0) { *COM_SkipPath(bindir) = 0; printf("Binary is located at "%s"\n", bindir);