]> source.dussan.org Git - rspamd.git/commitdiff
Fix printing of multiple mail addresses in the log
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 16 Nov 2015 09:13:54 +0000 (09:13 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 16 Nov 2015 09:13:54 +0000 (09:13 +0000)
src/libserver/task.c

index 11d8693a9d2e69b9f9c9ab836647f572fb978f4e..f89ca409768b94ee33f3e8e55d0d4fe6a9d368fe 100644 (file)
@@ -851,7 +851,7 @@ rspamd_task_write_ialist (struct rspamd_task *task,
                struct rspamd_log_format *lf,
                rspamd_fstring_t *logbuf)
 {
-       rspamd_fstring_t *res = logbuf;
+       rspamd_fstring_t *res = logbuf, *varbuf;
        rspamd_ftok_t var = {.begin = NULL, .len = 0};
        InternetAddressMailbox *iamb;
        InternetAddress *ia = NULL;
@@ -861,26 +861,33 @@ rspamd_task_write_ialist (struct rspamd_task *task,
                lim = internet_address_list_length (ialist);
        }
 
+       varbuf = rspamd_fstring_new ();
+
        for (i = 0; i < lim; i++) {
                ia = internet_address_list_get_address (ialist, i);
 
-               var.len = 0;
                if (ia && INTERNET_ADDRESS_IS_MAILBOX (ia)) {
                        iamb = INTERNET_ADDRESS_MAILBOX (ia);
-                       var.begin = iamb->addr;
-                       var.len = strlen (var.begin);
+                       varbuf = rspamd_fstring_append (varbuf, iamb->addr,
+                                       strlen (iamb->addr));
                }
 
-               if (var.len > 0) {
-                       res = rspamd_task_log_write_var (task, logbuf,
-                                       &var, (const rspamd_ftok_t *) lf->data);
-
+               if (varbuf->len > 0) {
                        if (i != lim - 1) {
-                               res = rspamd_fstring_append (res, ",", 1);
+                               varbuf = rspamd_fstring_append (varbuf, ",", 1);
                        }
                }
        }
 
+       if (varbuf->len > 0) {
+               var.begin = varbuf->str;
+               var.len = varbuf->len;
+               res = rspamd_task_log_write_var (task, logbuf,
+                               &var, (const rspamd_ftok_t *) lf->data);
+       }
+
+       rspamd_fstring_free (varbuf);
+
        return res;
 }