diff --git a/src/lib-sieve/sieve-actions.c b/src/lib-sieve/sieve-actions.c index 9b7d389e332f16b554d30661582808cebeb15759..5fb3ee44bef17b54cba9d4d18a18767bd668a178 100644 --- a/src/lib-sieve/sieve-actions.c +++ b/src/lib-sieve/sieve-actions.c @@ -121,7 +121,6 @@ static const struct sieve_extension_obj_registry * const struct sieve_side_effect *sieve_opr_side_effect_read (struct sieve_binary *sbin, sieve_size_t *address) { - unsigned int seffect_code; const struct sieve_operand *operand = sieve_operand_read(sbin, address); if ( operand == NULL || operand->class != &side_effect_class ) diff --git a/src/lib-sieve/sieve-binary.c b/src/lib-sieve/sieve-binary.c index be358a8589ff3ff92d3993c03f6ba12eb4a96829..663ea1cae04fcb7f3b339d32fd1460e5f8faa61c 100644 --- a/src/lib-sieve/sieve-binary.c +++ b/src/lib-sieve/sieve-binary.c @@ -1590,8 +1590,9 @@ bool sieve_binary_read_string if ( strlen > ADDR_BYTES_LEFT(binary, address) ) return FALSE; - - *str = t_str_const(&ADDR_CODE_AT(binary, address), strlen); + + if ( str != NULL ) + *str = t_str_const(&ADDR_CODE_AT(binary, address), strlen); ADDR_JUMP(address, strlen); if ( ADDR_CODE_AT(binary, address) != 0 ) diff --git a/src/lib-sieve/sieve-code.c b/src/lib-sieve/sieve-code.c index 9a95cf19bafe20ba15c8e3df38a318d28cd86c39..603a35770f224f9ac7549630077229df6145f2f3 100644 --- a/src/lib-sieve/sieve-code.c +++ b/src/lib-sieve/sieve-code.c @@ -58,7 +58,7 @@ bool sieve_coded_stringlist_next_item else { address = strlist->current_offset; - if ( sieve_binary_read_string(strlist->binary, &address, str) ) { + if ( sieve_opr_string_read(strlist->binary, &address, str) ) { strlist->index++; strlist->current_offset = address; return TRUE; @@ -213,7 +213,7 @@ static bool opr_string_dump (const struct sieve_dumptime_env *denv, sieve_size_t *address); const struct sieve_opr_string_interface string_interface ={ - opr_string_dump, + opr_string_dump, opr_string_read }; @@ -230,20 +230,12 @@ static bool opr_stringlist_dump (const struct sieve_dumptime_env *denv, sieve_size_t *address); static struct sieve_coded_stringlist *opr_stringlist_read (struct sieve_binary *sbin, sieve_size_t *address); -static struct sieve_coded_stringlist *opr_stringlist_read_single - (struct sieve_binary *sbin, sieve_size_t *address); const struct sieve_opr_stringlist_interface stringlist_interface = { opr_stringlist_dump, opr_stringlist_read }; -/* Read a single string as string list */ -const struct sieve_opr_stringlist_interface stringlist_single_interface = { - opr_stringlist_dump, - opr_stringlist_read_single -}; - const struct sieve_operand_class stringlist_class = { "string-list", &stringlist_interface }; @@ -386,7 +378,6 @@ bool sieve_opr_string_read return intf->read(sbin, address, str); } - static void _dump_string (const struct sieve_dumptime_env *denv, string_t *str) { @@ -439,7 +430,7 @@ void sieve_opr_stringlist_emit_start void sieve_opr_stringlist_emit_item (struct sieve_binary *sbin, void *context ATTR_UNUSED, string_t *item) { - (void) sieve_binary_emit_string(sbin, item); + (void) sieve_opr_string_emit(sbin, item); } void sieve_opr_stringlist_emit_end @@ -485,23 +476,34 @@ bool sieve_opr_stringlist_dump struct sieve_coded_stringlist *sieve_opr_stringlist_read (struct sieve_binary *sbin, sieve_size_t *address) { + sieve_size_t start = *address; const struct sieve_operand *operand = sieve_operand_read(sbin, address); - const struct sieve_opr_stringlist_interface *intf; - if ( operand == NULL) - return NULL; - - if ( operand->class == &stringlist_class ) - intf = (const struct sieve_opr_stringlist_interface *) operand->class->interface; - else if ( operand == &string_operand ) - intf = &stringlist_single_interface; - else + if ( operand == NULL ) return NULL; - if ( intf->read == NULL ) - return NULL; + if ( operand->class == &stringlist_class ) { + const struct sieve_opr_stringlist_interface *intf = + (const struct sieve_opr_stringlist_interface *) operand->class->interface; + + if ( intf->read == NULL ) + return NULL; - return intf->read(sbin, address); + return intf->read(sbin, address); + } else if ( operand->class == &string_class ) { + /* Special case, accept single string as string list as well. */ + const struct sieve_opr_string_interface *intf = + (const struct sieve_opr_string_interface *) operand->class->interface; + + if ( intf->read == NULL || !intf->read(sbin, address, NULL) ) { + printf("FAILED TO SKIP\n"); + return NULL; + } + + return sieve_coded_stringlist_create(sbin, start, 1, *address); + } + + return NULL; } static bool opr_stringlist_dump @@ -534,24 +536,6 @@ static bool opr_stringlist_dump return FALSE; } -static struct sieve_coded_stringlist *opr_stringlist_read_single - (struct sieve_binary *sbin, sieve_size_t *address ) -{ - struct sieve_coded_stringlist *strlist; - sieve_size_t strlen; - sieve_size_t pc = *address; - - if ( !sieve_binary_read_integer(sbin, address, &strlen) ) - return NULL; - - strlist = sieve_coded_stringlist_create(sbin, pc, 1, *address + strlen + 1); - - /* Skip over the string for now */ - *address += strlen + 1; - - return strlist; -} - static struct sieve_coded_stringlist *opr_stringlist_read (struct sieve_binary *sbin, sieve_size_t *address ) {