aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-10-01 12:04:33 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-10-01 12:04:33 +0100
commit56d73d7a1826d016a96b6ca374d43b80dce72c60 (patch)
tree01246e36eb6d5a2901588f8f99cf647fe504fadc
parent7a83d76dc12389438bbe3b0b29cc82b7740a3796 (diff)
downloadrspamd-56d73d7a1826d016a96b6ca374d43b80dce72c60.tar.gz
rspamd-56d73d7a1826d016a96b6ca374d43b80dce72c60.zip
Check type of InternetAddress.
-rw-r--r--src/libmime/expressions.c14
-rw-r--r--src/libserver/task.c14
-rw-r--r--src/plugins/regexp.c12
3 files changed, 26 insertions, 14 deletions
diff --git a/src/libmime/expressions.c b/src/libmime/expressions.c
index c6c7d7ddf..154649b51 100644
--- a/src/libmime/expressions.c
+++ b/src/libmime/expressions.c
@@ -1273,10 +1273,16 @@ rspamd_recipients_distance (struct rspamd_task *task, GList * args,
#ifdef GMIME24
for (i = 0; i < num; i++) {
addr = internet_address_list_get_address (cur, i);
- ar[i].name = internet_address_mailbox_get_addr (
- INTERNET_ADDRESS_MAILBOX (addr));
- if (ar[i].name != NULL && (c = strchr (ar[i].name, '@')) != NULL) {
- ar[i].addr = c + 1;
+ InternetAddress *iaelt =
+ internet_address_list_get_address(cur, i);
+ InternetAddressMailbox *iamb =
+ INTERNET_ADDRESS_IS_MAILBOX(iaelt) ?
+ INTERNET_ADDRESS_MAILBOX (iaelt) : NULL;
+ if (iamb) {
+ ar[i].name = internet_address_mailbox_get_addr (iamb);
+ if (ar[i].name != NULL && (c = strchr (ar[i].name, '@')) != NULL) {
+ ar[i].addr = c + 1;
+ }
}
}
#else
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 5eaa620fc..2cec9cb3a 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -350,16 +350,18 @@ rspamd_task_process (struct rspamd_task *task,
const gchar *
rspamd_task_get_sender (struct rspamd_task *task)
{
- InternetAddressMailbox *imb = NULL;
+ InternetAddressMailbox *imb;
+ InternetAddress *iaelt = NULL;
+
if (task->from_envelope != NULL) {
- imb = INTERNET_ADDRESS_MAILBOX(internet_address_list_get_address (
- task->from_envelope, 0));
+ iaelt = internet_address_list_get_address (task->from_envelope, 0);
}
else if (task->from_mime != NULL) {
- imb = INTERNET_ADDRESS_MAILBOX(internet_address_list_get_address (
- task->from_mime, 0));
+ iaelt = internet_address_list_get_address (task->from_mime, 0);
}
+ imb = INTERNET_ADDRESS_IS_MAILBOX(iaelt) ?
+ INTERNET_ADDRESS_MAILBOX (iaelt) : NULL;
- return internet_address_mailbox_get_addr (imb);
+ return (imb ? internet_address_mailbox_get_addr (imb) : NULL);
}
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 6b5cda269..f22a1503f 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -1357,9 +1357,11 @@ rspamd_check_smtp_data (struct rspamd_task *task, GList * args, void *unused)
else {
if (ia != NULL) {
for (i = 0; i < internet_address_list_length(ia); i ++) {
+ InternetAddress *iaelt =
+ internet_address_list_get_address(ia, i);
InternetAddressMailbox *iamb =
- INTERNET_ADDRESS_MAILBOX (
- internet_address_list_get_address(ia, i));
+ INTERNET_ADDRESS_IS_MAILBOX(iaelt) ?
+ INTERNET_ADDRESS_MAILBOX (iaelt) : NULL;
if (iamb &&
match_smtp_data (task, arg->data,
internet_address_mailbox_get_addr(iamb))) {
@@ -1379,9 +1381,11 @@ rspamd_check_smtp_data (struct rspamd_task *task, GList * args, void *unused)
else {
if (ia != NULL) {
for (i = 0; i < internet_address_list_length(ia); i ++) {
+ InternetAddress *iaelt =
+ internet_address_list_get_address(ia, i);
InternetAddressMailbox *iamb =
- INTERNET_ADDRESS_MAILBOX (
- internet_address_list_get_address(ia, i));
+ INTERNET_ADDRESS_IS_MAILBOX(iaelt) ?
+ INTERNET_ADDRESS_MAILBOX (iaelt) : NULL;
if (iamb &&
process_regexp_expression (arg->data,
"regexp_check_smtp_data", task,