Skip to content
Snippets Groups Projects
Commit 6d4b1ea5 authored by Stephan Bosch's avatar Stephan Bosch Committed by aki.tuomi
Browse files

testsuite: cmd-test-message - Properly check folder argument validity.

parent 1a661ed1
No related branches found
No related tags found
No related merge requests found
......@@ -195,7 +195,8 @@ $(test_cases):
failure_test_cases = \
tests/failures/fuzz1.svtest \
tests/failures/fuzz2.svtest
tests/failures/fuzz2.svtest \
tests/failures/mailbox-bad-utf8.svtest
$(failure_test_cases):
@$(TEST_BIN) -F $(top_srcdir)/$@
......
......@@ -2,12 +2,14 @@
*/
#include "lib.h"
#include "str-sanitize.h"
#include "istream.h"
#include "mail-storage.h"
#include "sieve-common.h"
#include "sieve-commands.h"
#include "sieve-message.h"
#include "sieve-actions.h"
#include "sieve-validator.h"
#include "sieve-generator.h"
#include "sieve-interpreter.h"
......@@ -253,6 +255,20 @@ cmd_test_message_validate_folder_tag(struct sieve_validator *valdtr,
return FALSE;
}
/* Check name validity when folder argument is not a variable */
if ( sieve_argument_is_string_literal(*arg) ) {
const char *folder = sieve_ast_argument_strc(*arg), *error;
if ( !sieve_mailbox_check_name(folder, &error) ) {
sieve_command_validate_error(
valdtr, cmd, "%s command: "
"invalid mailbox `%s' specified: %s",
sieve_command_identifier(cmd),
str_sanitize(folder, 256), error);
return FALSE;
}
}
/* Skip parameter */
*arg = sieve_ast_argument_next(*arg);
......@@ -450,6 +466,7 @@ cmd_test_message_mailbox_operation_execute(const struct sieve_runtime_env *renv,
sieve_number_t msg_index;
unsigned int is_test = 0;
bool result;
const char *error;
int ret;
/*
......@@ -472,6 +489,12 @@ cmd_test_message_mailbox_operation_execute(const struct sieve_runtime_env *renv,
if (ret <= 0)
return ret;
if (!sieve_mailbox_check_name(str_c(folder), &error)) {
return testsuite_test_failf(
renv, "invalid mailbox `%s' specified: %s",
str_c(folder), error);
}
/*
* Perform operation
*/
......
require "vnd.dovecot.testsuite";
require "encoded-character";
test "Mailbox parameter with bad UTF-8" {
test_message :folder "I${hex:9b}BOX" 0;
}
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.