[PR #6872] [MERGED] bugfix: firemon: fix potential memory leak in procevent_monitor #6208

Closed
opened 2026-05-05 10:52:45 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netblue30/firejail/pull/6872
Author: @kmk3
Created: 8/19/2025
Status: Merged
Merged: 8/20/2025
Merged by: @netblue30

Base: masterHead: procevent-fix-cmd-memleak


📝 Commits (1)

  • b45a80e bugfix: firemon: fix potential memory leak in procevent_monitor

📊 Changes

1 file changed (+10 additions, -6 deletions)

View changed files

📝 src/firemon/procevent.c (+10 -6)

📄 Description

Simplify the deallocation of cmd to make it easier to understand,
which looks like it would fix a potential memory leak of cmd:

if (!cmd) {
    cmd = pid_proc_cmdline(pid); // alloc
}
if (add_new) {
    // ...                       // no dealloc
}
else if (proc_ev->what == PROC_EVENT_EXIT && pids[pid].level == 1) {
    // ...                       // no dealloc
}
else {
    // ...
    else {
        sprintf(lineptr, " %s\n", cmd);
        if (cmd != pids[pid].option.event.cmd) {
            free(cmd);           // dealloc
        }
    }
    // ...
}

This is a follow-up to commit 5ec00f70c ("fix: avoid cmd double-free in
procevent_monitor", 2025-07-31) / PR #6846.

Relates to #6792.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netblue30/firejail/pull/6872 **Author:** [@kmk3](https://github.com/kmk3) **Created:** 8/19/2025 **Status:** ✅ Merged **Merged:** 8/20/2025 **Merged by:** [@netblue30](https://github.com/netblue30) **Base:** `master` ← **Head:** `procevent-fix-cmd-memleak` --- ### 📝 Commits (1) - [`b45a80e`](https://github.com/netblue30/firejail/commit/b45a80e660ed73d4d54ee597a3656e7fd2a71739) bugfix: firemon: fix potential memory leak in procevent_monitor ### 📊 Changes **1 file changed** (+10 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/firemon/procevent.c` (+10 -6) </details> ### 📄 Description Simplify the deallocation of `cmd` to make it easier to understand, which looks like it would fix a potential memory leak of `cmd`: if (!cmd) { cmd = pid_proc_cmdline(pid); // alloc } if (add_new) { // ... // no dealloc } else if (proc_ev->what == PROC_EVENT_EXIT && pids[pid].level == 1) { // ... // no dealloc } else { // ... else { sprintf(lineptr, " %s\n", cmd); if (cmd != pids[pid].option.event.cmd) { free(cmd); // dealloc } } // ... } This is a follow-up to commit 5ec00f70c ("fix: avoid cmd double-free in procevent_monitor", 2025-07-31) / PR #6846. Relates to #6792. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 10:52:45 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#6208
No description provided.