Skip to content

Commit

Permalink
doveadm: Use a separate memory pool for parsing doveadm command line …
Browse files Browse the repository at this point in the history
…parameters

This avoids spending a lot of the data stack for the actual command
processing, causing them to grow the data stack.
  • Loading branch information
sirainen committed Dec 2, 2024
1 parent abcba28 commit a3aee24
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/doveadm/doveadm-cmd-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,14 @@ int doveadm_cmdline_run(int argc, const char *const argv[],
{
ARRAY_TYPE(doveadm_cmd_param_arr_t) pargv;
unsigned int pargc;
pool_t pool = pool_datastack_create();
pool_t pool = pool_alloconly_create("doveadm cmdline", 1024);

i_getopt_reset();
p_array_init(&pargv, pool, 20);
if (doveadm_cmd_process_options(argc, argv, cctx, pool, &pargv) < 0)
if (doveadm_cmd_process_options(argc, argv, cctx, pool, &pargv) < 0) {
pool_unref(&pool);
return -1;
}

unsigned int ptr_count;
struct doveadm_cmd_param *ptr = array_get_modifiable(&pargv, &ptr_count);
Expand Down Expand Up @@ -411,6 +413,7 @@ int doveadm_cmdline_run(int argc, const char *const argv[],
e_error(cctx->event, "Invalid parameter: %s",
t_strarray_join(argv + optind, " "));
doveadm_cmd_params_clean(&pargv);
pool_unref(&pool);
return -1;
}
found = TRUE;
Expand All @@ -420,6 +423,7 @@ int doveadm_cmdline_run(int argc, const char *const argv[],
e_error(cctx->event, "Extraneous arguments found: %s",
t_strarray_join(argv + optind, " "));
doveadm_cmd_params_clean(&pargv);
pool_unref(&pool);
return -1;
}
if (is_keyvalue)
Expand All @@ -439,6 +443,7 @@ int doveadm_cmdline_run(int argc, const char *const argv[],
cctx->cmd->cmd(cctx);

doveadm_cmd_params_clean(&pargv);
pool_unref(&pool);
return 0;
}

Expand Down

0 comments on commit a3aee24

Please sign in to comment.