mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-21 06:45:29 -06:00
Merge pull request #6872 from kmk3/procevent-fix-cmd-memleak
bugfix: firemon: fix potential memory leak in procevent_monitor
This commit is contained in:
commit
6b1b7794a8
1 changed files with 10 additions and 6 deletions
|
|
@ -471,8 +471,10 @@ static void __attribute__((noreturn)) procevent_monitor(const int sock, pid_t my
|
|||
|
||||
|
||||
int sandbox_closed = 0; // exit sandbox flag
|
||||
int cmd_dup = 0;
|
||||
char *cmd = pids[pid].option.event.cmd;
|
||||
if (!cmd) {
|
||||
cmd_dup = 1;
|
||||
cmd = pid_proc_cmdline(pid);
|
||||
}
|
||||
if (add_new) {
|
||||
|
|
@ -490,20 +492,22 @@ static void __attribute__((noreturn)) procevent_monitor(const int sock, pid_t my
|
|||
}
|
||||
else {
|
||||
if (!cmd) {
|
||||
cmd_dup = 1;
|
||||
cmd = pid_proc_cmdline(pid);
|
||||
}
|
||||
if (cmd == NULL || nodisplay)
|
||||
if (!cmd || nodisplay)
|
||||
sprintf(lineptr, "\n");
|
||||
else {
|
||||
else
|
||||
sprintf(lineptr, " %s\n", cmd);
|
||||
if (cmd != pids[pid].option.event.cmd) {
|
||||
free(cmd);
|
||||
}
|
||||
}
|
||||
lineptr += strlen(lineptr);
|
||||
}
|
||||
(void) lineptr;
|
||||
|
||||
if (cmd && cmd_dup) {
|
||||
free(cmd);
|
||||
cmd = NULL;
|
||||
}
|
||||
|
||||
// print the event
|
||||
printf("%s", line);
|
||||
fflush(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue