forked from pool/dovecot23
Marcus Rueckert
c8ae08e7fc
fixes crash with imap sieve OBS-URL: https://build.opensuse.org/package/show/server:mail/dovecot23?expand=0&rev=2
62 lines
2.7 KiB
Diff
62 lines
2.7 KiB
Diff
From 321a39be974deb2e7eff7b2a509a3ee6ff2e5ae1 Mon Sep 17 00:00:00 2001
|
|
From: Stephan Bosch <stephan.bosch@dovecot.fi>
|
|
Date: Mon, 25 Dec 2017 18:20:14 +0100
|
|
Subject: [PATCH] plugins: sieve-extprograms: Fix segfault occurring when used
|
|
in IMAPSieve 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.
|
|
---
|
|
.../sieve-extprograms/sieve-extprograms-common.c | 29 +++++++++++++---------
|
|
1 file changed, 17 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/src/plugins/sieve-extprograms/sieve-extprograms-common.c b/src/plugins/sieve-extprograms/sieve-extprograms-common.c
|
|
index 8fef2f53..5f0ed728 100644
|
|
--- a/src/plugins/sieve-extprograms/sieve-extprograms-common.c
|
|
+++ b/src/plugins/sieve-extprograms/sieve-extprograms-common.c
|
|
@@ -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;
|
|
@@ -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;
|