Skip to content

Commit

Permalink
plugins: sieve-extprograms: Fix segfault occurring when used in IMAPS…
Browse files Browse the repository at this point in the history
…ieve context.

This was caused by recent lib-smtp changes.
There is no envelope in IMAPSieve context, so the rcpt parameters are NULL, causing the segfault.
  • Loading branch information
stephanbosch committed Jan 4, 2018
1 parent d68c23a commit 6413898
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/plugins/sieve-extprograms/sieve-extprograms-common.c
Expand Up @@ -415,6 +415,7 @@ struct sieve_extprogram *sieve_extprogram_create
struct sieve_instance *svinst = ext->svinst;
struct sieve_extprograms_config *ext_config =
(struct sieve_extprograms_config *) ext->context;
const struct smtp_address *sender, *recipient, *orig_recipient;
struct sieve_extprogram *sprog;
const char *path = NULL;
struct stat st;
Expand Down Expand Up @@ -549,20 +550,24 @@ struct sieve_extprogram *sieve_extprogram_create
program_client_set_env(sprog->program_client, "HOME", svinst->home_dir);
if ( svinst->hostname != NULL )
program_client_set_env(sprog->program_client, "HOST", svinst->hostname);
if ( !smtp_address_isnull(msgdata->envelope.mail_from) ) {
program_client_set_env
(sprog->program_client, "SENDER",
smtp_address_encode(msgdata->envelope.mail_from));

sender = msgdata->envelope.mail_from;
recipient = msgdata->envelope.rcpt_to;
orig_recipient = NULL;
if ( msgdata->envelope.rcpt_params != NULL )
orig_recipient = msgdata->envelope.rcpt_params->orcpt.addr;

if ( !smtp_address_isnull(sender) ) {
program_client_set_env(sprog->program_client, "SENDER",
smtp_address_encode(sender));
}
if ( !smtp_address_isnull(msgdata->envelope.rcpt_to) ) {
program_client_set_env
(sprog->program_client, "RECIPIENT",
smtp_address_encode(msgdata->envelope.rcpt_to));
if ( !smtp_address_isnull(recipient) ) {
program_client_set_env(sprog->program_client, "RECIPIENT",
smtp_address_encode(recipient));
}
if ( !smtp_address_isnull(msgdata->envelope.rcpt_params->orcpt.addr) ) {
program_client_set_env
(sprog->program_client, "ORIG_RECIPIENT",
smtp_address_encode(msgdata->envelope.rcpt_params->orcpt.addr));
if ( !smtp_address_isnull(orig_recipient) ) {
program_client_set_env(sprog->program_client, "ORIG_RECIPIENT",
smtp_address_encode(orig_recipient));
}

return sprog;
Expand Down

0 comments on commit 6413898

Please sign in to comment.