mirror of https://github.com/xzeldon/htop.git
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)";
|
cmdline = "(zombie)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(cmdlineBasenameOffset >= 0);
|
||||||
|
assert(cmdlineBasenameOffset <= strlen(cmdline));
|
||||||
|
|
||||||
if (!showMergedCommand || !procExe || !procComm) { /* fall back to cmdline */
|
if (!showMergedCommand || !procExe || !procComm) { /* fall back to cmdline */
|
||||||
if (showMergedCommand && !procExe && procComm && strlen(procComm)) { /* Prefix column with comm */
|
if (showMergedCommand && !procExe && procComm && strlen(procComm)) { /* Prefix column with comm */
|
||||||
if (strncmp(cmdline + cmdlineBasenameOffset, procComm, MINIMUM(TASK_COMM_LEN - 1, strlen(procComm))) != 0) {
|
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 exeBasenameOffset = lp->procExeBasenameOffset;
|
||||||
int exeBasenameLen = exeLen - exeBasenameOffset;
|
int exeBasenameLen = exeLen - exeBasenameOffset;
|
||||||
|
|
||||||
|
assert(exeBasenameOffset >= 0);
|
||||||
|
assert(exeBasenameOffset <= strlen(procExe));
|
||||||
|
|
||||||
/* Start with copying exe */
|
/* Start with copying exe */
|
||||||
if (showProgramPath) {
|
if (showProgramPath) {
|
||||||
str = stpcpy(str, procExe);
|
str = stpcpy(str, procExe);
|
||||||
|
|
Loading…
Reference in New Issue