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

testsuite: Properly check address value parsed from message.

Caused a panic when input was not valid. This is only relevant to the test suite
and doesn't occur anywhere else (apart from the previous similar commit for
lib-sieve-tool).

Panic was:

Panic in file smtp-address.c: line 684 (smtp_address_write): assertion failed: (smtp_char_is_qpair(*p))`
parent 39e9b39e
No related branches found
No related tags found
No related merge requests found
...@@ -48,6 +48,7 @@ static const struct smtp_address * ...@@ -48,6 +48,7 @@ static const struct smtp_address *
testsuite_message_get_address(struct mail *mail, const char *header) testsuite_message_get_address(struct mail *mail, const char *header)
{ {
struct message_address *addr; struct message_address *addr;
struct smtp_address *smtp_addr;
const char *str; const char *str;
if (mail_get_first_header(mail, header, &str) <= 0) if (mail_get_first_header(mail, header, &str) <= 0)
...@@ -57,7 +58,9 @@ testsuite_message_get_address(struct mail *mail, const char *header) ...@@ -57,7 +58,9 @@ testsuite_message_get_address(struct mail *mail, const char *header)
strlen(str), 1, 0); strlen(str), 1, 0);
if (addr == NULL || addr->mailbox == NULL || *addr->mailbox == '\0') if (addr == NULL || addr->mailbox == NULL || *addr->mailbox == '\0')
return NULL; return NULL;
return smtp_address_create_temp(addr->mailbox, addr->domain); if (smtp_address_create_from_msg_temp(addr, &smtp_addr) < 0)
return NULL;
return smtp_addr;
} }
static void testsuite_message_set_data(struct mail *mail) static void testsuite_message_set_data(struct mail *mail)
......
...@@ -155,3 +155,45 @@ test "Cc" { ...@@ -155,3 +155,45 @@ test "Cc" {
test_fail "envelope sender not null"; test_fail "envelope sender not null";
} }
} }
test_result_reset;
test_set "message" text:
From: stephan@example.org
Subject: No subject of discussion
To: nicëøôçêè—öxample.org
Frop
.
;
test "Bad recipient address (from message)" {
vacation :subject "Tulips" "I am not in today!";
if not test_result_execute {
test_fail "execution of result failed";
}
}
test_result_reset;
test_set "message" text:
From: stephan@example.org
Subject: No subject of discussion
To: tss@example.net
Frop
.
;
test_set "envelope.to" "nicëøôçêè—öxample.org";
test "Bad recipient address (from envelope)" {
vacation :subject "Tulips" "I am not in today!";
if not test_result_execute {
test_fail "execution of result failed";
}
}
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.