Fix read from uninitialized part of buffer

According to "man 2 readlink": "readlink() does not append a null byte to buf."
I have no idea how this worked up to now.
This commit is contained in:
Turo Lamminen 2017-03-14 22:55:33 +02:00 committed by Daniel Gibson
parent 5da6374663
commit 9e628e8474

View file

@ -109,6 +109,11 @@ bool Sys_GetPath(sysPath_t type, idStr &path) {
idStr::snPrintf(buf, sizeof(buf), "/proc/%d/exe", getpid());
len = readlink(buf, buf2, sizeof(buf2));
if (len != -1) {
if (len < MAX_OSPATH) {
buf2[len] = '\0';
} else {
buf2[MAX_OSPATH - 1] = '\0';
}
path = buf2;
return true;
}