commit:     f87e4803e1b20b6161c05509c5d68152166569c5
Author:     Mathias Krause <minipli <AT> grsecurity <DOT> net>
AuthorDate: Tue Jul 30 21:18:27 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Aug  9 10:02:43 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=f87e4803

pspax: fix libcap memory leaks

Every cap_t needs to be free'd by calling cap_free() which does a NULL
pointer test itself so callers don't need to.

Signed-off-by: Mathias Krause <minipli <AT> grsecurity.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 pspax.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/pspax.c b/pspax.c
index 4cd09b6..b61e7d0 100644
--- a/pspax.c
+++ b/pspax.c
@@ -345,8 +345,6 @@ static void pspax(const char *find_name)
        int pfd;
        WRAP_SYSCAP(ssize_t length; cap_t cap_d;)
 
-       WRAP_SYSCAP(cap_d = cap_init());
-
        dir = opendir(PROC_DIR);
        if (dir == NULL || chdir(PROC_DIR))
                errp(PROC_DIR);
@@ -438,7 +436,8 @@ static void pspax(const char *find_name)
                                print_executable_mappings(pfd);
                }
 
-               WRAP_SYSCAP(if (caps) cap_free(caps));
+               WRAP_SYSCAP(cap_free(cap_d));
+               WRAP_SYSCAP(cap_free(caps));
 
  next_pid:
                close(pfd);

Reply via email to