Skip to content

Commit

Permalink
Fix leak in create_bogo_n_arg
Browse files Browse the repository at this point in the history
When running with ASAN and UBSAN on ubuntu 22 u00000.vtc and m00003.vtc
fails from a leak from the return value of create_bogo_n_arg() in
mgt_main.c. Freeing the returned value allows tests to pass.
  • Loading branch information
stevendore committed Feb 23, 2024
1 parent 6ea6c93 commit 569c68a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions bin/varnishd/mgt/mgt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ mgt_process_f_arg(struct cli *cli, unsigned C_flag, void **fap)
return (retval);
}

static const char *
static char *
create_bogo_n_arg(void)
{
struct vsb *vsb;
Expand Down Expand Up @@ -807,8 +807,11 @@ main(int argc, char * const *argv)

assert(d_flag == 0 || F_flag == 0);

if (C_flag && n_arg == NULL)
n_arg = create_bogo_n_arg();
p = NULL;
if (C_flag && n_arg == NULL) {
p = create_bogo_n_arg();
n_arg = p;
}

if (S_arg != NULL && !strcmp(S_arg, "none")) {
fprintf(stderr,
Expand All @@ -825,6 +828,8 @@ main(int argc, char * const *argv)

workdir = VIN_n_Arg(n_arg);
AN(workdir);
if (p != NULL)
free(p);

if (i_arg == NULL || *i_arg == '\0')
i_arg = mgt_HostName();
Expand Down

0 comments on commit 569c68a

Please sign in to comment.