dovecot-2.2-pigeonhole: Merged changes from v0.3 tree.

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Mon Sep 16 02:17:30 EEST 2013


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/b1db52d0c0b3
changeset: 1802:b1db52d0c0b3
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Mon Sep 16 01:15:55 2013 +0200
description:
Merged changes from v0.3 tree.

diffstat:

 src/lib-sieve/plugins/variables/cmd-set.c |  74 +++++++++++++++---------------
 src/lib-sieve/sieve-binary-code.c         |   6 +-
 src/lib-sieve/sieve-binary-dumper.c       |  10 ++--
 3 files changed, 44 insertions(+), 46 deletions(-)

diffs (166 lines):

diff -r 8be59d267be3 -r b1db52d0c0b3 src/lib-sieve/plugins/variables/cmd-set.c
--- a/src/lib-sieve/plugins/variables/cmd-set.c	Sun Sep 15 12:47:33 2013 +0200
+++ b/src/lib-sieve/plugins/variables/cmd-set.c	Mon Sep 16 01:15:55 2013 +0200
@@ -315,58 +315,56 @@
 	if ( str_len(value) > EXT_VARIABLES_MAX_VARIABLE_SIZE )
 		str_truncate(value, EXT_VARIABLES_MAX_VARIABLE_SIZE);
 
-	T_BEGIN {
-		/* Apply modifiers if necessary (sorted during code generation already) */
+	/* Apply modifiers if necessary (sorted during code generation already) */
+	for ( i = 0; i < mdfs; i++ ) {
+		string_t *new_value;
+		struct sieve_variables_modifier modf;
+
+		if ( !ext_variables_opr_modifier_read(renv, address, &modf) ) {
+			value = NULL;
+			ret = SIEVE_EXEC_BIN_CORRUPT;
+			break;
+		}
+
 		if ( str_len(value) > 0 ) {
-			for ( i = 0; i < mdfs; i++ ) {
-				string_t *new_value;
-				struct sieve_variables_modifier modf;
-
-				if ( !ext_variables_opr_modifier_read(renv, address, &modf) ) {
+			if ( modf.def != NULL && modf.def->modify != NULL ) {
+				if ( !modf.def->modify(value, &new_value) ) {
 					value = NULL;
-					ret = SIEVE_EXEC_BIN_CORRUPT;
+					ret = SIEVE_EXEC_FAILURE;
 					break;
 				}
 
-				if ( modf.def != NULL && modf.def->modify != NULL ) {
-					if ( !modf.def->modify(value, &new_value) ) {
-						value = NULL;
-						ret = SIEVE_EXEC_FAILURE;
-						break;
-					}
+				sieve_runtime_trace_here
+					(renv, SIEVE_TRLVL_COMMANDS, "modify :%s \"%s\" => \"%s\"",
+						sieve_variables_modifier_name(&modf), str_c(value), str_c(new_value));
 
-					sieve_runtime_trace_here
-						(renv, SIEVE_TRLVL_COMMANDS, "modify :%s \"%s\" => \"%s\"",
-							sieve_variables_modifier_name(&modf), str_c(value), str_c(new_value));
+				value = new_value;
+				if ( value == NULL )
+					break;
 
-					value = new_value;
-					if ( value == NULL )
-						break;
-
-					/* Hold value within limits */
-					if ( str_len(value) > EXT_VARIABLES_MAX_VARIABLE_SIZE )
-						str_truncate(value, EXT_VARIABLES_MAX_VARIABLE_SIZE);
-				}
+				/* Hold value within limits */
+				if ( str_len(value) > EXT_VARIABLES_MAX_VARIABLE_SIZE )
+					str_truncate(value, EXT_VARIABLES_MAX_VARIABLE_SIZE);
 			}
 		}
+	}
 
-		/* Actually assign the value if all is well */
-		if ( value != NULL ) {
-			if ( !sieve_variable_assign(storage, var_index, value) )
-				ret = SIEVE_EXEC_BIN_CORRUPT;
-			else {
-				if ( sieve_runtime_trace_active(renv, SIEVE_TRLVL_COMMANDS) ) {
-					const char *var_name, *var_id;
+	/* Actually assign the value if all is well */
+	if ( value != NULL ) {
+		if ( !sieve_variable_assign(storage, var_index, value) )
+			ret = SIEVE_EXEC_BIN_CORRUPT;
+		else {
+			if ( sieve_runtime_trace_active(renv, SIEVE_TRLVL_COMMANDS) ) {
+				const char *var_name, *var_id;
 
-					(void)sieve_variable_get_identifier(storage, var_index, &var_name);
-					var_id = sieve_variable_get_varid(storage, var_index);
+				(void)sieve_variable_get_identifier(storage, var_index, &var_name);
+				var_id = sieve_variable_get_varid(storage, var_index);
 
-					sieve_runtime_trace_here(renv, 0, "assign `%s' [%s] = \"%s\"",
-						var_name, var_id, str_c(value));
-				}
+				sieve_runtime_trace_here(renv, 0, "assign `%s' [%s] = \"%s\"",
+					var_name, var_id, str_c(value));
 			}
 		}
-	} T_END;
+	}
 
 	if ( ret <= 0 ) return ret;
 	if ( value == NULL ) return SIEVE_EXEC_FAILURE;
diff -r 8be59d267be3 -r b1db52d0c0b3 src/lib-sieve/sieve-binary-code.c
--- a/src/lib-sieve/sieve-binary-code.c	Sun Sep 15 12:47:33 2013 +0200
+++ b/src/lib-sieve/sieve-binary-code.c	Mon Sep 16 01:15:55 2013 +0200
@@ -214,7 +214,7 @@
 	((const int8_t *) (&_code[*address]))
 
 #define ADDR_BYTES_LEFT(address) \
-	((_code_size) - (*address))
+	((*address) > _code_size ? 0 : ((_code_size) - (*address)))
 #define ADDR_JUMP(address, offset) \
 	(*address) += offset
 
@@ -350,7 +350,7 @@
 
 	ADDR_CODE_READ(sblock);
 
-	if ( ADDR_BYTES_LEFT(address) <= 0 )
+	if ( ADDR_BYTES_LEFT(address) == 0 )
 		return FALSE;
 
 	(*offset_r) = code = ADDR_DATA_AT(address);
@@ -382,7 +382,7 @@
 	if ( objs->count == 1 )
 		return objs->objects;
 
-	if ( ADDR_BYTES_LEFT(address) <= 0 )
+	if ( ADDR_BYTES_LEFT(address) == 0 )
 		return NULL;
 
 	code = ADDR_DATA_AT(address);
diff -r 8be59d267be3 -r b1db52d0c0b3 src/lib-sieve/sieve-binary-dumper.c
--- a/src/lib-sieve/sieve-binary-dumper.c	Sun Sep 15 12:47:33 2013 +0200
+++ b/src/lib-sieve/sieve-binary-dumper.c	Mon Sep 16 01:15:55 2013 +0200
@@ -218,10 +218,10 @@
 		buffer_t *blockbuf = sieve_binary_block_get_buffer(sblock);
 		string_t *line;
 		size_t data_size;
-		const char *data;
+		const unsigned char *data;
 		size_t offset;
 
-		data = (const char *) buffer_get_data(blockbuf, &data_size);
+		data = buffer_get_data(blockbuf, &data_size);
 
 		// FIXME: calculate offset more nicely.
 		sieve_binary_dump_sectionf
@@ -237,7 +237,7 @@
 			str_printfa(line, "%08llx  ", (unsigned long long) offset);
 
 			for ( b = 0; b < len; b++ ) {
-				str_printfa(line, "%02x ", (unsigned int) data[offset+b]);
+				str_printfa(line, "%02x ", data[offset+b]);
 				if ( b == 7 ) str_append_c(line, ' ');
 			}
 
@@ -252,10 +252,10 @@
 			str_append(line, " |");
 
 			for ( b = 0; b < len; b++ ) {
-				const char c = data[offset+b];
+				const unsigned char c = data[offset+b];
 
 				if ( c >= 32 && c <= 126 )
-					str_append_c(line, c);
+					str_append_c(line, (const char)c);
 				else
 					str_append_c(line, '.');
 			}


More information about the dovecot-cvs mailing list