Skip to content

Commit

Permalink
free_cmndspec: plug apparmor_profile leak
Browse files Browse the repository at this point in the history
  • Loading branch information
millert committed May 3, 2024
1 parent 89918ca commit 07d6aa2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugins/sudoers/gram.c
Original file line number Diff line number Diff line change
Expand Up @@ -3763,6 +3763,11 @@ free_cmndspec(struct cmndspec *cs, struct cmndspec_list *csl)
(next == NULL || cs->type != next->type)) {
free(cs->type);
}
/* Don't free apparmor_profile that is in use by other entries. */
if ((prev == NULL || cs->apparmor_profile != prev->apparmor_profile) &&
(next == NULL || cs->apparmor_profile != next->apparmor_profile)) {
free(cs->apparmor_profile);
}
/* Don't free privs/limitprivs that are in use by other entries. */
if ((prev == NULL || cs->privs != prev->privs) &&
(next == NULL || cs->privs != next->privs)) {
Expand Down
5 changes: 5 additions & 0 deletions plugins/sudoers/gram.y
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,11 @@ free_cmndspec(struct cmndspec *cs, struct cmndspec_list *csl)
(next == NULL || cs->type != next->type)) {
free(cs->type);
}
/* Don't free apparmor_profile that is in use by other entries. */
if ((prev == NULL || cs->apparmor_profile != prev->apparmor_profile) &&
(next == NULL || cs->apparmor_profile != next->apparmor_profile)) {
free(cs->apparmor_profile);
}
/* Don't free privs/limitprivs that are in use by other entries. */
if ((prev == NULL || cs->privs != prev->privs) &&
(next == NULL || cs->privs != next->privs)) {
Expand Down

0 comments on commit 07d6aa2

Please sign in to comment.