Skip to content
Snippets Groups Projects
Commit fb9c630e authored by Stephan Bosch's avatar Stephan Bosch Committed by timo.sirainen
Browse files

lib-sieve: plugins: imap4flags: test-hasflag - Fix segfault occurring for...

lib-sieve: plugins: imap4flags: test-hasflag - Fix segfault occurring for command without arguments.
parent f0116c92
No related branches found
No related tags found
No related merge requests found
......@@ -102,6 +102,7 @@ test_cases = \
tests/extensions/include/rfc.svtest \
tests/extensions/include/execute.svtest \
tests/extensions/imap4flags/basic.svtest \
tests/extensions/imap4flags/errors.svtest \
tests/extensions/imap4flags/hasflag.svtest \
tests/extensions/imap4flags/execute.svtest \
tests/extensions/imap4flags/multiscript.svtest \
......
......@@ -99,8 +99,6 @@ static bool
tst_hasflag_validate(struct sieve_validator *valdtr,
struct sieve_command *tst)
{
struct sieve_ast_argument *vars = tst->first_positional;
struct sieve_ast_argument *keys = sieve_ast_argument_next(vars);
const struct sieve_match_type mcht_default =
SIEVE_MATCH_TYPE_DEFAULT(is_match_type);
const struct sieve_comparator cmp_default =
......@@ -109,6 +107,9 @@ tst_hasflag_validate(struct sieve_validator *valdtr,
if (!ext_imap4flags_command_validate(valdtr, tst))
return FALSE;
struct sieve_ast_argument *vars = tst->first_positional;
struct sieve_ast_argument *keys = sieve_ast_argument_next(vars);
if (keys == NULL) {
keys = vars;
vars = NULL;
......
require "vnd.dovecot.testsuite";
require "relational";
require "comparator-i;ascii-numeric";
/*
* Invalid syntax
*/
test "Invalid Syntax" {
if test_script_compile "errors/syntax.sieve" {
test_fail "compile should have failed";
}
if not test_error :count "eq" :comparator "i;ascii-numeric" "31" {
test_fail "wrong number of errors reported";
}
}
require "imap4flags";
# 1-10: Used incorrectly as a command vs test
if setflag {}
if addflag {}
if removeflag {}
if setflag;
if addflag;
if removeflag;
hasflag;
# 11-19: Used with no argument
setflag;
addflag;
removeflag;
if hasflag {}
if hasflag;
if not hasflag {}
if not hasflag;
# Used with one string argument (OK)
setflag "frop";
addflag "frop";
removeflag "frop";
if hasflag "frop" {}
# 20-25: Used with one number argument
setflag 234234;
addflag 23423;
removeflag 234234;
if hasflag 234234 {}
if hasflag 234234;
# Used with one string list argument (OK)
setflag ["frop"];
addflag ["frop"];
removeflag ["frop"];
if hasflag ["frop"] {}
# 26-30: Used with unknown tag
setflag :frop "frop";
addflag :frop "frop";
removeflag :frop "frop";
if hasflag :frop "frop" {}
if hasflag :frop "frop";
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.