From 79ba9d7a68e7697b83b36b997137e946d2dd4eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 23 Jan 2024 18:51:00 +0800 Subject: [PATCH] TerminalShell (Linux): fix segfault --- src/detection/terminalshell/terminalshell_linux.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index e0615a418..1366ae686 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -147,10 +147,13 @@ static const char* getProcessNameAndPpid(pid_t pid, char* name, pid_t* ppid, int ) return "sscanf(stat) failed"; - if (tty && (tty_ >> 8) == 0x88) - *tty = tty_ & 0xFF; - else - *tty = -1; + if (tty) + { + if ((tty_ >> 8) == 0x88) + *tty = tty_ & 0xFF; + else + *tty = -1; + } #elif defined(__APPLE__)