Add the argument vector allocated for -s and -i mode to the garbage
collector list. Avoids an ASAN warning on exit when the -s or -i flags are used.
This commit is contained in:
@@ -464,6 +464,9 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
||||
cmnd = dst = reallocarray(NULL, cmnd_size, 2);
|
||||
if (cmnd == NULL)
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
if (!gc_add(GC_PTR, cmnd))
|
||||
exit(1);
|
||||
|
||||
for (av = argv; *av != NULL; av++) {
|
||||
for (src = *av; *src != '\0'; src++) {
|
||||
/* quote potential meta characters */
|
||||
@@ -483,6 +486,9 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
||||
av = reallocarray(NULL, ac + 1, sizeof(char *));
|
||||
if (av == NULL)
|
||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||
if (!gc_add(GC_PTR, av))
|
||||
exit(1);
|
||||
|
||||
av[0] = (char *)user_details.shell; /* plugin may override shell */
|
||||
if (cmnd != NULL) {
|
||||
av[1] = "-c";
|
||||
|
@@ -89,11 +89,7 @@ static int sudo_mode;
|
||||
|
||||
struct sudo_gc_entry {
|
||||
SLIST_ENTRY(sudo_gc_entry) entries;
|
||||
enum sudo_gc_types {
|
||||
GC_UNKNOWN,
|
||||
GC_VECTOR,
|
||||
GC_PTR
|
||||
} type;
|
||||
enum sudo_gc_types type;
|
||||
union {
|
||||
char **vec;
|
||||
void *ptr;
|
||||
@@ -113,7 +109,6 @@ static void sudo_check_suid(const char *path);
|
||||
static char **get_user_info(struct user_details *);
|
||||
static void command_info_to_details(char * const info[],
|
||||
struct command_details *details);
|
||||
static bool gc_add(enum sudo_gc_types type, void *ptr);
|
||||
static void gc_init(void);
|
||||
|
||||
/* Policy plugin convenience functions. */
|
||||
@@ -1509,7 +1504,7 @@ iolog_unlink(struct plugin_container *plugin)
|
||||
debug_return;
|
||||
}
|
||||
|
||||
static bool
|
||||
bool
|
||||
gc_add(enum sudo_gc_types type, void *v)
|
||||
{
|
||||
#ifdef NO_LEAKS
|
||||
|
@@ -180,7 +180,12 @@ struct command_status {
|
||||
int val;
|
||||
};
|
||||
|
||||
struct timeval;
|
||||
/* Garbage collector data types. */
|
||||
enum sudo_gc_types {
|
||||
GC_UNKNOWN,
|
||||
GC_VECTOR,
|
||||
GC_PTR
|
||||
};
|
||||
|
||||
/* For fatal() and fatalx() (XXX - needed?) */
|
||||
void cleanup(int);
|
||||
@@ -206,6 +211,7 @@ bool exec_setup(struct command_details *details, const char *ptyname, int ptyfd)
|
||||
int policy_init_session(struct command_details *details);
|
||||
int run_command(struct command_details *details);
|
||||
int os_init_common(int argc, char *argv[], char *envp[]);
|
||||
bool gc_add(enum sudo_gc_types type, void *v);
|
||||
extern const char *list_user;
|
||||
extern struct user_details user_details;
|
||||
extern int sudo_debug_instance;
|
||||
|
Reference in New Issue
Block a user