From 68f6584593807de2b8d9e9ec694d55e52bc0b32d Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Wed, 5 Aug 2009 12:47:27 +0200
Subject: [PATCH] Side-effect argumennt registrations were not using the
 SIEVE_OPT_SIDE_EFFECT constant.

---
 src/lib-sieve/plugins/copy/ext-copy.c                    | 6 ++++--
 src/lib-sieve/plugins/imap4flags/cmd-flag.c              | 4 ++++
 src/lib-sieve/plugins/imap4flags/ext-imap4flags-common.c | 2 +-
 src/lib-sieve/plugins/imap4flags/tag-flags.c             | 5 +++++
 src/lib-sieve/plugins/mailbox/ext-mailbox.c              | 2 +-
 src/lib-sieve/sieve-actions.h                            | 2 +-
 src/lib-sieve/sieve-code.h                               | 2 +-
 7 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/lib-sieve/plugins/copy/ext-copy.c b/src/lib-sieve/plugins/copy/ext-copy.c
index e15d2ec06..12786a1a8 100644
--- a/src/lib-sieve/plugins/copy/ext-copy.c
+++ b/src/lib-sieve/plugins/copy/ext-copy.c
@@ -55,8 +55,10 @@ static bool ext_copy_validator_load(struct sieve_validator *validator)
 	 * whether these commands are registered or even whether they will be
 	 * registered at all. The validator handles either situation gracefully 
 	 */
-	sieve_validator_register_external_tag(validator, &copy_tag, "redirect", -1);
-	sieve_validator_register_external_tag(validator, &copy_tag, "fileinto", -1);
+	sieve_validator_register_external_tag
+		(validator, &copy_tag, "redirect", SIEVE_OPT_SIDE_EFFECT);
+	sieve_validator_register_external_tag
+		(validator, &copy_tag, "fileinto", SIEVE_OPT_SIDE_EFFECT);
 
 	return TRUE;
 }
diff --git a/src/lib-sieve/plugins/imap4flags/cmd-flag.c b/src/lib-sieve/plugins/imap4flags/cmd-flag.c
index b0187085c..6654b24c2 100644
--- a/src/lib-sieve/plugins/imap4flags/cmd-flag.c
+++ b/src/lib-sieve/plugins/imap4flags/cmd-flag.c
@@ -155,6 +155,10 @@ bool cmd_flag_operation_dump
 	
 	sieve_code_mark(denv);
 	operand = sieve_operand_read(denv->sbin, address);
+	if ( operand == NULL ) {
+		sieve_code_dumpf(denv, "ERROR: INVALID OPERAND");
+		return FALSE;
+	}
 
 	if ( sieve_operand_is_variable(operand) ) {	
 		return 
diff --git a/src/lib-sieve/plugins/imap4flags/ext-imap4flags-common.c b/src/lib-sieve/plugins/imap4flags/ext-imap4flags-common.c
index ee975b0fe..6ef032a17 100644
--- a/src/lib-sieve/plugins/imap4flags/ext-imap4flags-common.c
+++ b/src/lib-sieve/plugins/imap4flags/ext-imap4flags-common.c
@@ -152,7 +152,7 @@ void ext_imap4flags_attach_flags_tag
 	 
 	/* Tag specified by user */
 	sieve_validator_register_external_tag
-		(valdtr, &tag_flags, command, -1);
+		(valdtr, &tag_flags, command, SIEVE_OPT_SIDE_EFFECT);
 
     /* Implicit tag if none is specified */
 	sieve_validator_register_persistent_tag
diff --git a/src/lib-sieve/plugins/imap4flags/tag-flags.c b/src/lib-sieve/plugins/imap4flags/tag-flags.c
index 5755f05f6..6a85ab94b 100644
--- a/src/lib-sieve/plugins/imap4flags/tag-flags.c
+++ b/src/lib-sieve/plugins/imap4flags/tag-flags.c
@@ -196,6 +196,11 @@ static bool seff_flags_dump_context
     const struct sieve_operand *operand;
 
     operand = sieve_operand_read(denv->sbin, address);
+	if ( operand == NULL ) {
+		sieve_code_dumpf(denv, "ERROR: INVALID OPERAND");
+		return FALSE;
+	}
+
 
     if ( sieve_operand_is_omitted(operand) ) {
 		sieve_code_dumpf(denv, "flags: INTERNAL");
diff --git a/src/lib-sieve/plugins/mailbox/ext-mailbox.c b/src/lib-sieve/plugins/mailbox/ext-mailbox.c
index 3419e3c90..bb777923c 100644
--- a/src/lib-sieve/plugins/mailbox/ext-mailbox.c
+++ b/src/lib-sieve/plugins/mailbox/ext-mailbox.c
@@ -51,7 +51,7 @@ static bool ext_mailbox_validator_load(struct sieve_validator *valdtr)
 	 * validator handles either situation gracefully 
 	 */
 	sieve_validator_register_external_tag
-		(valdtr, &mailbox_create_tag, "fileinto", -1);
+		(valdtr, &mailbox_create_tag, "fileinto", SIEVE_OPT_SIDE_EFFECT);
 
 	/* Register new test */
 	sieve_validator_register_command(valdtr, &mailboxexists_test);
diff --git a/src/lib-sieve/sieve-actions.h b/src/lib-sieve/sieve-actions.h
index 901e5050f..8a735274b 100644
--- a/src/lib-sieve/sieve-actions.h
+++ b/src/lib-sieve/sieve-actions.h
@@ -153,7 +153,7 @@ struct sieve_side_effect {
 #define SIEVE_EXT_DEFINE_SIDE_EFFECT(SEF) SIEVE_EXT_DEFINE_OBJECT(SEF)
 #define SIEVE_EXT_DEFINE_SIDE_EFFECTS(SEFS) SIEVE_EXT_DEFINE_OBJECTS(SEFS)
 
-#define SIEVE_OPT_SIDE_EFFECT -1
+#define SIEVE_OPT_SIDE_EFFECT (-1)
 
 extern const struct sieve_operand_class sieve_side_effect_operand_class;
 
diff --git a/src/lib-sieve/sieve-code.h b/src/lib-sieve/sieve-code.h
index db38e7d90..984a1bc6a 100644
--- a/src/lib-sieve/sieve-code.h
+++ b/src/lib-sieve/sieve-code.h
@@ -79,7 +79,7 @@ bool sieve_operand_optional_read
 /* Operand codes */
 
 enum sieve_core_operand {
-	SIEVE_OPERAND_OPTIONAL,
+	SIEVE_OPERAND_OPTIONAL = 0x00,
 	SIEVE_OPERAND_NUMBER,
 	SIEVE_OPERAND_STRING,
 	SIEVE_OPERAND_STRING_LIST,
-- 
GitLab