dovecot-2.1-pigeonhole: lib-sieve: deprecated notify extension: ...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Mon Nov 11 02:31:24 EET 2013


details:   http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/44f659981723
changeset: 1704:44f659981723
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Mon Nov 11 01:31:08 2013 +0100
description:
lib-sieve: deprecated notify extension: Fixed segfault problems in message string substitution.

diffstat:

 src/lib-sieve/plugins/notify/ext-notify-common.c |  12 +++---
 tests/deprecated/notify/basic.svtest             |  48 ++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 6 deletions(-)

diffs (95 lines):

diff -r 406f6cc2f1e1 -r 44f659981723 src/lib-sieve/plugins/notify/ext-notify-common.c
--- a/src/lib-sieve/plugins/notify/ext-notify-common.c	Sat Nov 09 11:42:07 2013 +0100
+++ b/src/lib-sieve/plugins/notify/ext-notify-common.c	Mon Nov 11 01:31:08 2013 +0100
@@ -243,14 +243,14 @@
 	/* Scan message for substitutions */
 	p = msg_format;
 	while ( *p != '\0' ) {
-		const char *const *header;
+		const char *header;
 
 		if ( strncasecmp(p, "$from$", 6) == 0 ) {
 			p += 6;
 
-			/* Fetch sender from oriinal message */
-			if ( mail_get_headers_utf8(msgdata->mail, "from", &header) >= 0 )
-				 str_append(out_msg, header[0]);
+			/* Fetch sender from original message */
+			if ( mail_get_first_header_utf8(msgdata->mail, "from", &header) > 0 )
+				 str_append(out_msg, header);
 
 		} else if ( strncasecmp(p, "$env-from$", 10) == 0 ) {
 			p += 10;
@@ -262,8 +262,8 @@
 			p += 9;
 
 			/* Fetch sender from oriinal message */
-			if ( mail_get_headers_utf8(msgdata->mail, "subject", &header) >= 0 )
-				 str_append(out_msg, header[0]);
+			if ( mail_get_first_header_utf8(msgdata->mail, "subject", &header) > 0 )
+				 str_append(out_msg, header);
 
 		} else if ( strncasecmp(p, "$text", 5) == 0
 			&& (p[5] == '[' || p[5] == '$') ) {
diff -r 406f6cc2f1e1 -r 44f659981723 tests/deprecated/notify/basic.svtest
--- a/tests/deprecated/notify/basic.svtest	Sat Nov 09 11:42:07 2013 +0100
+++ b/tests/deprecated/notify/basic.svtest	Mon Nov 11 01:31:08 2013 +0100
@@ -1,5 +1,6 @@
 require "vnd.dovecot.testsuite";
 require "notify";
+require "body";
 
 test "Execute" {
 	/* Test to catch runtime segfaults */
@@ -8,4 +9,51 @@
 		:low
 		:method "mailto"
 		:options ["stephan at example.com", "stephan at example.org"];
+
+	if not test_result_execute {
+		test_fail "Execute failed";
+	}
 }
+
+test_result_reset;
+
+test_set "message" text:
+To: user at example.com
+From: stephan at example.org
+Subject: Mail
+
+Test!
+.
+;
+
+test "Substitutions" {
+	notify
+		:message "$from$: $subject$"
+		:options "stephan at example.com";
+	if not test_result_execute {
+		test_fail "Execute failed";
+	}
+	test_message :smtp 0;
+	if not body :contains "stephan at example.org: Mail" {
+		test_fail "Substitution failed";
+	}
+}
+
+test_result_reset;
+
+test_set "message" text:
+To: user at example.com
+
+Test!
+.
+;
+
+test "Empty substitutions" {
+	notify
+		:message "$from$: $subject$"
+		:options "stephan at example.com";
+	if not test_result_execute {
+		test_fail "Execute failed";
+	}
+}
+


More information about the dovecot-cvs mailing list