From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Sven Eckelmann <sven@narfation.org>
Subject: [PATCH 2/2] alfred: free the correct capability set when cap_init() fails
Date: Wed, 29 Jul 2026 08:26:29 +0200 [thread overview]
Message-ID: <20260729-bugfixes-libcap-v1-2-23529745c828@narfation.org> (raw)
In-Reply-To: <20260729-bugfixes-libcap-v1-0-23529745c828@narfation.org>
reduce_capabilities() first allocates the current capability state with
cap_get_proc() into cap_cur and then allocates a fresh capability set
with cap_init() into cap_new. When the latter fails it tries to deallocate
the NULL cap_new.
Free cap_cur instead to avoid a leak.
Fixes: b0877b387ba1 ("alfred: Drop capabilities when not needed")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/main.c b/main.c
index 9c38fd7..07e3cca 100644
--- a/main.c
+++ b/main.c
@@ -84,7 +84,7 @@ static int reduce_capabilities(void)
cap_new = cap_init();
if (!cap_new) {
perror("cap_init");
- cap_free(cap_new);
+ cap_free(cap_cur);
return -1;
}
--
2.47.3
prev parent reply other threads:[~2026-07-29 6:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 6:26 [PATCH 0/2] alfred: libcap: random fixes Sven Eckelmann
2026-07-29 6:26 ` [PATCH 1/2] alfred: drop CAP_NET_RAW when binding to the device fails Sven Eckelmann
2026-07-29 6:26 ` Sven Eckelmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260729-bugfixes-libcap-v1-2-23529745c828@narfation.org \
--to=sven@narfation.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox