Skip to content

Commit

Permalink
pspax: fix libcap memory leaks
Browse files Browse the repository at this point in the history
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@grsecurity.net>
Signed-off-by: Sam James <sam@gentoo.org>
  • Loading branch information
minipli-oss authored and thesamesam committed Aug 9, 2024
1 parent 6641785 commit f87e480
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pspax.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f87e480

Please sign in to comment.