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

lib-sieve: Do not allow UTF-8 in localpart in addresses parsed from Sieve script.

parent 2c1c4220
No related branches found
No related tags found
No related merge requests found
......@@ -265,6 +265,20 @@ static inline void sieve_address_error
* MERGE!
*/
static int check_local_part(struct sieve_message_address_parser *ctx)
{
const unsigned char *p, *pend;
p = str_data(ctx->local_part);
pend = p + str_len(ctx->local_part);
while (p < pend) {
if (*p < 0x20 || *p > 0x7e)
return -1;
p++;
}
return 0;
}
static int parse_local_part(struct sieve_message_address_parser *ctx)
{
int ret;
......@@ -302,7 +316,7 @@ static int parse_local_part(struct sieve_message_address_parser *ctx)
} while (ret > 0 && *ctx->parser.data == '.');
}
if (ret < 0) {
if (ret < 0 || check_local_part(ctx) < 0) {
sieve_address_error(ctx, "invalid local part");
return -1;
}
......
......@@ -307,7 +307,7 @@ test "Outgoing address errors (FIXME: count only)" {
test_fail "compile should have failed.";
}
if not test_error :count "eq" :comparator "i;ascii-numeric" "15" {
if not test_error :count "eq" :comparator "i;ascii-numeric" "16" {
test_fail "wrong number of errors reported";
}
}
......
......@@ -15,6 +15,7 @@ redirect "Error <stephan";
redirect "Error <stephan@";
redirect "stephan@example.org,tss@example.net";
redirect "stephan@example.org,%&^&!!~";
redirect "rüdiger@example.com";
vacation :from "Error" "Ik ben er niet.";
......
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.