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

lib-sieve: index extension: Do not accept :index tag with zero value.

parent a46bb1a9
No related branches found
No related tags found
No related merge requests found
......@@ -122,6 +122,13 @@ tag_index_validate(struct sieve_validator *valdtr ATTR_UNUSED,
}
data->fieldno = sieve_ast_argument_number(*arg);
if (data->fieldno == 0) {
sieve_argument_validate_error(valdtr, *arg,
"the :index tag for the %s %s cannot be zero",
sieve_command_identifier(cmd),
sieve_command_type_name(cmd));
return FALSE;
}
/* Detach parameter */
*arg = sieve_ast_arguments_detach(*arg,1);
......@@ -204,7 +211,8 @@ svmo_index_dump_context(const struct sieve_message_override *svmo ATTR_UNUSED,
sieve_number_t fieldno = 0;
unsigned int last;
if (!sieve_binary_read_integer(denv->sblock, address, &fieldno))
if (!sieve_binary_read_integer(denv->sblock, address, &fieldno) ||
fieldno == 0)
return FALSE;
sieve_code_dumpf(denv, "fieldno: %llu", (unsigned long long) fieldno);
......@@ -231,6 +239,10 @@ svmo_index_read_context(const struct sieve_message_override *svmo ATTR_UNUSED,
sieve_runtime_trace_error(renv, "fieldno: invalid number");
return SIEVE_EXEC_BIN_CORRUPT;
}
if (fieldno == 0) {
sieve_runtime_trace_error(renv, "fieldno: index is zero");
return SIEVE_EXEC_BIN_CORRUPT;
}
if (!sieve_binary_read_byte(renv->sblock, address, &last)) {
sieve_runtime_trace_error(renv, "last: invalid byte");
return SIEVE_EXEC_BIN_CORRUPT;
......
......@@ -12,7 +12,7 @@ test "Invalid Syntax" {
test_fail "compile should have failed";
}
if not test_error :count "eq" :comparator "i;ascii-numeric" "5" {
if not test_error :count "eq" :comparator "i;ascii-numeric" "7" {
test_fail "wrong number of errors reported";
}
}
......
......@@ -18,3 +18,9 @@ if header :index "frop" "to" "ok" {}
# 4: last without index
if header :last "to" "ok" {}
# 5: index 0
if header :index 0 "to" "ok" {}
# 6: index 0 last
if header :index 0 :last "to" "ok" {}
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.