Skip to content

Commit cb13d43

Browse files
committed
TerminalShell (Linux): always ignore pid1 (v2)
1 parent bd7190c commit cb13d43

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/detection/terminalshell/terminalshell_linux.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid)
3131
userShellName = instance.state.platform.userShell.chars + index + 1;
3232
}
3333

34-
while (ffProcessGetBasicInfoLinux(pid, &result->processName, &ppid, &tty) == NULL)
34+
while (pid > 1 && ffProcessGetBasicInfoLinux(pid, &result->processName, &ppid, &tty) == NULL)
3535
{
3636
if (!ffStrbufEqualS(&result->processName, userShellName))
3737
{
@@ -75,14 +75,14 @@ static pid_t getShellInfo(FFShellResult* result, pid_t pid)
7575
ffProcessGetInfoLinux(pid, &result->processName, &result->exe, &result->exeName, &result->exePath);
7676
break;
7777
}
78-
return ppid;
78+
return pid > 1 ? ppid : 0;
7979
}
8080

8181
static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
8282
{
8383
pid_t ppid = 0;
8484

85-
while (ffProcessGetBasicInfoLinux(pid, &result->processName, &ppid, NULL) == NULL)
85+
while (pid > 1 && ffProcessGetBasicInfoLinux(pid, &result->processName, &ppid, NULL) == NULL)
8686
{
8787
//Known shells
8888
if (
@@ -145,7 +145,7 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
145145
ffProcessGetInfoLinux(pid, &result->processName, &result->exe, &result->exeName, &result->exePath);
146146
break;
147147
}
148-
return ppid;
148+
return pid > 1 ? ppid : 0;
149149
}
150150

151151
static bool getTerminalInfoByPidEnv(FFTerminalResult* result, const char* pidEnv)

0 commit comments

Comments
 (0)