]> source.dussan.org Git - rspamd.git/commitdiff
Check type of InternetAddress.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 1 Oct 2014 11:04:33 +0000 (12:04 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 1 Oct 2014 11:04:33 +0000 (12:04 +0100)
src/libmime/expressions.c
src/libserver/task.c
src/plugins/regexp.c

index c6c7d7ddfb1a952a72882ecc8923e3deaa932fe4..154649b516fcd2f7118d7be6af49497021a4e96b 100644 (file)
@@ -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
index 5eaa620fc4c278b66c07948bc6ef0772ec53f59d..2cec9cb3a2a073edf6c4a423011aa0415c656a52 100644 (file)
@@ -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);
 }
index 6b5cda269900319331722b2fe97eec3eca246d0a..f22a1503fbe4c7b35e376b18b5ccaeee43429b4e 100644 (file)
@@ -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,