mirror of https://github.com/xzeldon/htop.git
Merge branch 'harden_makecommandstr' of https://github.com/BenBE/htop into BenBE-harden_makecommandstr
This commit is contained in:
commit
fc7aead36b
|
@ -368,6 +368,16 @@ void LinuxProcess_makeCommandStr(Process* this) {
|
||||||
char *str = strStart;
|
char *str = strStart;
|
||||||
|
|
||||||
int cmdlineBasenameOffset = lp->procCmdlineBasenameOffset;
|
int cmdlineBasenameOffset = lp->procCmdlineBasenameOffset;
|
||||||
|
int cmdlineBasenameEnd = lp->procCmdlineBasenameEnd;
|
||||||
|
|
||||||
|
if (!cmdline) {
|
||||||
|
cmdlineBasenameOffset = 0;
|
||||||
|
cmdlineBasenameEnd = 0;
|
||||||
|
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 */
|
||||||
|
@ -385,11 +395,11 @@ void LinuxProcess_makeCommandStr(Process* this) {
|
||||||
if (showProgramPath) {
|
if (showProgramPath) {
|
||||||
(void) stpcpyWithNewlineConversion(str, cmdline);
|
(void) stpcpyWithNewlineConversion(str, cmdline);
|
||||||
mc->baseStart = cmdlineBasenameOffset;
|
mc->baseStart = cmdlineBasenameOffset;
|
||||||
mc->baseEnd = lp->procCmdlineBasenameEnd;
|
mc->baseEnd = cmdlineBasenameEnd;
|
||||||
} else {
|
} else {
|
||||||
(void) stpcpyWithNewlineConversion(str, cmdline + cmdlineBasenameOffset);
|
(void) stpcpyWithNewlineConversion(str, cmdline + cmdlineBasenameOffset);
|
||||||
mc->baseStart = 0;
|
mc->baseStart = 0;
|
||||||
mc->baseEnd = lp->procCmdlineBasenameEnd - cmdlineBasenameOffset;
|
mc->baseEnd = cmdlineBasenameEnd - cmdlineBasenameOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc->sep1) {
|
if (mc->sep1) {
|
||||||
|
@ -404,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