InitSystem (SunOS): fix crashes

This commit is contained in:
Carter Li
2024-06-17 15:18:02 +08:00
parent 94fb7eabfd
commit 76b8446d15
+9 -6
View File
@@ -247,13 +247,16 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
ffStrbufSubstrBeforeFirstC(exe, ' ');
}
snprintf(filePath, sizeof(filePath), "/proc/%d/path/a.out", (int) pid);
ffStrbufEnsureFixedLengthFree(exePath, PATH_MAX);
ssize_t length = readlink(filePath, exePath->chars, exePath->allocated - 1);
if (length > 0) // doesn't contain trailing NUL
if (exePath)
{
exePath->chars[length] = '\0';
exePath->length = (uint32_t) length;
snprintf(filePath, sizeof(filePath), "/proc/%d/path/a.out", (int) pid);
ffStrbufEnsureFixedLengthFree(exePath, PATH_MAX);
ssize_t length = readlink(filePath, exePath->chars, exePath->allocated - 1);
if (length > 0) // doesn't contain trailing NUL
{
exePath->chars[length] = '\0';
exePath->length = (uint32_t) length;
}
}
#endif