Skip to content

Commit

Permalink
Terminal (Linux): fix segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
CarterLi committed Jan 30, 2024
1 parent 53cd1e5 commit aaa091f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/detection/terminalshell/terminalshell_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,11 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)

static bool getTerminalInfoByPidEnv(FFTerminalResult* result, const char* pidEnv)
{
pid_t pid = (pid_t) strtol(getenv(pidEnv), NULL, 10);
const char* envStr = getenv(pidEnv);
if (envStr == NULL)
return false;

pid_t pid = (pid_t) strtol(envStr, NULL, 10);
result->pid = (uint32_t) pid;
char name[256];
if (getProcessNameAndPpid(pid, name, (pid_t*) &result->ppid, NULL) == NULL)
Expand Down

0 comments on commit aaa091f

Please sign in to comment.