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

lib-sieve: plugins: mailbox: tst-mailboxexists - Check mailbox name validity at runtime.

Fixes assert failure occurring at runtime (when value originates from variable).
parent 0659935e
No related branches found
No related tags found
No related merge requests found
......@@ -157,6 +157,17 @@ tst_mailboxexists_test_mailbox(const struct sieve_runtime_env *renv,
{
const struct sieve_execute_env *eenv = renv->exec_env;
struct mailbox *box;
const char *error;
/* Check validity of mailbox name */
if (!sieve_mailbox_check_name(mailbox, &error)) {
sieve_runtime_warning(
renv, NULL, "mailboxexists test: "
"invalid mailbox name `%s' specified: %s",
str_sanitize(mailbox, 256), error);
*all_exist_r = FALSE;
return SIEVE_EXEC_OK;
}
/* Open the box */
box = mailbox_alloc_for_user(eenv->scriptenv->user,
......
......@@ -20,4 +20,21 @@ test "Invalid Syntax" {
}
}
/*
* Mailboxexists - bad UTF-8 in mailbox name
*/
test "Mailboxexists - bad UTF-8 in mailbox name" {
if not test_script_compile "errors/mailboxexists-bad-utf8.sieve" {
test_fail "compile failed";
}
if not test_script_run {
test_fail "execution failed";
}
# FIXME: check warnings
if not test_error :count "eq" :comparator "i;ascii-numeric" "0" {
test_fail "wrong number of runtime errors reported";
}
}
require "mailbox";
require "variables";
require "encoded-character";
set "mailbox" "${hex:ff}rop";
if mailboxexists "${mailbox}" {
keep;
}
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.