Skip to content

Commit

Permalink
apply_cmndspec: plug potential memory leak
Browse files Browse the repository at this point in the history
If apply_cmndspec() is called where the cmndspec defines an apparmor
profile or Solaris privileges, and then is called again with a
cmndspec that does not have those set we would leak the original
value.
  • Loading branch information
millert committed May 6, 2024
1 parent 43ffe34 commit f2a979f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/sudoers/lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ apply_cmndspec(struct sudoers_context *ctx, struct cmndspec *cs)
debug_return_bool(false);
}
} else {
free(ctx->runas.apparmor_profile);
ctx->runas.apparmor_profile = def_apparmor_profile;
def_apparmor_profile = NULL;
}
Expand All @@ -384,6 +385,7 @@ apply_cmndspec(struct sudoers_context *ctx, struct cmndspec *cs)
debug_return_bool(false);
}
} else {
free(ctx->runas.privs);
ctx->runas.privs = def_privs;
def_privs = NULL;
}
Expand All @@ -400,6 +402,7 @@ apply_cmndspec(struct sudoers_context *ctx, struct cmndspec *cs)
debug_return_bool(false);
}
} else {
free(ctx->runas.limitprivs);
ctx->runas.limitprivs = def_limitprivs;
def_limitprivs = NULL;
}
Expand Down

0 comments on commit f2a979f

Please sign in to comment.