1
0
Fork 0
forked from fte/fteqw

readlink doesn't null terminate. oops.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4591 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2014-01-16 07:03:40 +00:00
parent 4f48db148c
commit 026939f58d

View file

@ -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);