mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
bugfix: lib: fix memory leaks in syscall_in_list() (#7098)
`asprintf()` overwrites the value of `ptr->xxx` with the new pointer. Result: the older allocation is never freed.
This commit is contained in:
parent
e01e2c1740
commit
05e0d44288
1 changed files with 6 additions and 2 deletions
|
|
@ -2669,8 +2669,10 @@ static void syscall_in_list(int fd, int syscall, int arg, void *ptrarg, bool nat
|
|||
// if found in the problem list, add to post-exec list
|
||||
if (sl.found) {
|
||||
if (ptr->postlist) {
|
||||
if (asprintf(&ptr->postlist, "%s,%s", ptr->postlist, name) == -1)
|
||||
char *old = ptr->postlist;
|
||||
if (asprintf(&ptr->postlist, "%s,%s", old, name) == -1)
|
||||
errExit("asprintf");
|
||||
free(old);
|
||||
}
|
||||
else
|
||||
ptr->postlist = strdup(name);
|
||||
|
|
@ -2689,8 +2691,10 @@ static void syscall_in_list(int fd, int syscall, int arg, void *ptrarg, bool nat
|
|||
}
|
||||
|
||||
if (ptr->prelist) {
|
||||
if (asprintf(&ptr->prelist, "%s,%s", ptr->prelist, newcall) == -1)
|
||||
char *old = ptr->prelist;
|
||||
if (asprintf(&ptr->prelist, "%s,%s", old, newcall) == -1)
|
||||
errExit("asprintf");
|
||||
free(old);
|
||||
free(newcall);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue