mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-03-21 02:01:03 +00:00
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:
parent
5da6374663
commit
9e628e8474
1 changed files with 5 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue