Skip to content
Snippets Groups Projects
Commit e01cb4d9 authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Merged changes from v0.3 tree.

parents d8269667 ed345afe
No related branches found
No related tags found
No related merge requests found
......@@ -315,58 +315,56 @@ static int cmd_set_operation_execute
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) */
if ( str_len(value) > 0 ) {
for ( i = 0; i < mdfs; i++ ) {
string_t *new_value;
struct sieve_variables_modifier modf;
/* 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 ( !ext_variables_opr_modifier_read(renv, address, &modf) ) {
if ( str_len(value) > 0 ) {
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;
......
......@@ -214,7 +214,7 @@ void sieve_binary_emit_extension_object
((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 @@ bool sieve_binary_read_extension
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 @@ const void *sieve_binary_read_extension_object
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);
......
......@@ -218,10 +218,10 @@ void sieve_binary_dumper_hexdump
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 @@ void sieve_binary_dumper_hexdump
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 @@ void sieve_binary_dumper_hexdump
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, '.');
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.