Mercurial > dovecot > core-2.2
changeset 22068:f294b577cf76
lib-program-client: local: Fixed use of unterminated string array of environment variables in exec_child().
author | Stephan Bosch <stephan.bosch@dovecot.fi> |
---|---|
date | Tue, 09 May 2017 13:43:39 +0200 |
parents | 2fae66df5b58 |
children | e6d9a30177c5 |
files | src/lib-program-client/program-client-local.c |
diffstat | 1 files changed, 9 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-program-client/program-client-local.c Tue May 09 14:22:06 2017 +0200 +++ b/src/lib-program-client/program-client-local.c Tue May 09 13:43:39 2017 +0200 @@ -45,7 +45,8 @@ void program_client_local_exited(struct program_client_local *plclient); static -void exec_child(const char *bin_path, const char *const *args, const char *const *envs, +void exec_child(const char *bin_path, const char *const *args, + ARRAY_TYPE(const_string) *envs, int in_fd, int out_fd, int *extra_fds, bool drop_stderr) { ARRAY_TYPE(const_string) exec_args; @@ -111,9 +112,12 @@ /* Setup environment */ env_clean(); - if (envs != NULL) { - for(; *envs != NULL; envs++) - env_put(*envs); + if (array_is_created(envs)) { + const char *const *env; + + array_foreach(envs, env) { + env_put(*env); + } } /* Execute */ @@ -216,9 +220,6 @@ } if (plclient->pid == 0) { - unsigned int count; - const char *const *envs = NULL; - /* child */ if (fd_in[1] >= 0 && close(fd_in[1]) < 0) i_error("close(pipe:in:wr) failed: %m"); @@ -239,10 +240,7 @@ restrict_access(&pclient->set.restrict_set, pclient->set.home, !pclient->set.allow_root); - if (array_is_created(&pclient->envs)) - envs = array_get(&pclient->envs, &count); - - exec_child(pclient->path, pclient->args, envs, + exec_child(pclient->path, pclient->args, &pclient->envs, fd_in[0], fd_out[1], child_extra_fds, pclient->set.drop_stderr); i_unreached();