Skip to content

Commit

Permalink
Merge pull request #5079 from dilyanpalauzov/http_cgi_use_after_free_…
Browse files Browse the repository at this point in the history
…environ

http_cgi.c:service_main() avoid use after free(environ)
  • Loading branch information
ksmurchison authored Oct 14, 2024
2 parents 4c5fa1d + 8ed20db commit 71ae1e3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions imap/http_cgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,16 @@ static int meth_get(struct transaction_t *txn,

env = strarray_splitm(NULL, buf_release(&txn->buf), "\t", 0);
strarray_append(env, NULL);
char **const environ_orig = environ;
environ = env->data;

/* Run script */
if (command_popen(&cmd, "rw", cwd, script, NULL)) {
ret = HTTP_SERVER_ERROR;
environ = environ_orig;
goto done;
}
environ = environ_orig;

/* Send request body */
prot_putbuf(cmd->stdin_prot, &txn->req_body.payload);
Expand Down

0 comments on commit 71ae1e3

Please sign in to comment.