mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
DiD: Ensure string offsets are inside string boundaries
This commit is contained in:
parent
10c6810bff
commit
6502b02666
@ -376,6 +376,9 @@ void LinuxProcess_makeCommandStr(Process* this) {
|
||||
cmdline = "(zombie)";
|
||||
}
|
||||
|
||||
assert(cmdlineBasenameOffset >= 0);
|
||||
assert(cmdlineBasenameOffset <= strlen(cmdline));
|
||||
|
||||
if (!showMergedCommand || !procExe || !procComm) { /* fall back to cmdline */
|
||||
if (showMergedCommand && !procExe && procComm && strlen(procComm)) { /* Prefix column with comm */
|
||||
if (strncmp(cmdline + cmdlineBasenameOffset, procComm, MINIMUM(TASK_COMM_LEN - 1, strlen(procComm))) != 0) {
|
||||
@ -411,6 +414,9 @@ void LinuxProcess_makeCommandStr(Process* this) {
|
||||
int exeBasenameOffset = lp->procExeBasenameOffset;
|
||||
int exeBasenameLen = exeLen - exeBasenameOffset;
|
||||
|
||||
assert(exeBasenameOffset >= 0);
|
||||
assert(exeBasenameOffset <= strlen(procExe));
|
||||
|
||||
/* Start with copying exe */
|
||||
if (showProgramPath) {
|
||||
str = stpcpy(str, procExe);
|
||||
|
Loading…
Reference in New Issue
Block a user