diff options
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/protocol.c | 12 | ||||
-rw-r--r-- | src/libserver/roll_history.c | 6 | ||||
-rw-r--r-- | src/libserver/task.c | 30 |
3 files changed, 28 insertions, 20 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index ff332d1cc..8834529ee 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -858,7 +858,7 @@ urls_protocol_cb (gpointer key, gpointer value, gpointer ud) } msg_notice_task_encrypted ("<%s> %s: %*s; ip: %s; URL: %*s", - MESSAGE_FIELD (task, message_id), + MESSAGE_FIELD_CHECK (task, message_id), has_user ? "user" : "from", len, user_field, rspamd_inet_address_to_string (task->from_addr), @@ -935,7 +935,7 @@ rspamd_protocol_rewrite_subject (struct rspamd_task *task) } p = c; - s = MESSAGE_FIELD (task, subject); + s = MESSAGE_FIELD_CHECK (task, subject); if (s) { slen = strlen (s); @@ -1285,7 +1285,7 @@ rspamd_protocol_write_ucl (struct rspamd_task *task, } } - if (flags & RSPAMD_PROTOCOL_URLS) { + if (flags & RSPAMD_PROTOCOL_URLS && task->message) { if (g_hash_table_size (MESSAGE_FIELD (task, urls)) > 0) { ucl_object_insert_key (top, rspamd_urls_tree_ucl (MESSAGE_FIELD (task, urls), task), @@ -1307,7 +1307,7 @@ rspamd_protocol_write_ucl (struct rspamd_task *task, if (flags & RSPAMD_PROTOCOL_BASIC) { ucl_object_insert_key (top, - ucl_object_fromstring (MESSAGE_FIELD (task, message_id)), + ucl_object_fromstring (MESSAGE_FIELD_CHECK (task, message_id)), "message-id", 0, false); ucl_object_insert_key (top, ucl_object_fromdouble (task->time_real_finish - task->task_timestamp), @@ -1331,7 +1331,7 @@ rspamd_protocol_write_ucl (struct rspamd_task *task, GString *folded_header; dkim_sig = (GString *) dkim_sigs->data; - if (task->flags & RSPAMD_TASK_FLAG_MILTER) { + if (task->flags & RSPAMD_TASK_FLAG_MILTER || !task->message) { folded_header = rspamd_header_value_fold ("DKIM-Signature", dkim_sig->str, 80, RSPAMD_TASK_NEWLINES_LF, NULL); } @@ -1792,7 +1792,7 @@ rspamd_protocol_write_reply (struct rspamd_task *task, ev_tstamp timeout) if (rspamd_http_connection_is_encrypted (task->http_conn)) { msg_info_protocol ("<%s> writing encrypted reply", - MESSAGE_FIELD (task, message_id)); + MESSAGE_FIELD_CHECK (task, message_id)); } if (!RSPAMD_TASK_IS_JSON (task)) { diff --git a/src/libserver/roll_history.c b/src/libserver/roll_history.c index ee69d59d3..ceed8d04f 100644 --- a/src/libserver/roll_history.c +++ b/src/libserver/roll_history.c @@ -140,8 +140,10 @@ rspamd_roll_history_update (struct roll_history *history, row->timestamp = task->task_timestamp; /* Strings */ - rspamd_strlcpy (row->message_id, MESSAGE_FIELD (task, message_id), - sizeof (row->message_id)); + if (task->message) { + rspamd_strlcpy (row->message_id, MESSAGE_FIELD (task, message_id), + sizeof (row->message_id)); + } if (task->user) { rspamd_strlcpy (row->user, task->user, sizeof (row->user)); } diff --git a/src/libserver/task.c b/src/libserver/task.c index dfad41220..950af5ec8 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -930,7 +930,7 @@ rspamd_task_get_principal_recipient (struct rspamd_task *task) } } - GPtrArray *rcpt_mime = MESSAGE_FIELD (task, rcpt_mime); + GPtrArray *rcpt_mime = MESSAGE_FIELD_CHECK (task, rcpt_mime); if (rcpt_mime != NULL && rcpt_mime->len > 0) { PTR_ARRAY_FOREACH (rcpt_mime, i, addr) { if (addr->addr && !(addr->flags & RSPAMD_EMAIL_ADDR_ORIGINAL)) { @@ -969,7 +969,7 @@ rspamd_task_log_check_condition (struct rspamd_task *task, switch (lf->type) { case RSPAMD_LOG_MID: - if (MESSAGE_FIELD (task, message_id) && + if (MESSAGE_FIELD_CHECK (task, message_id) && strcmp (MESSAGE_FIELD (task, message_id) , "undef") != 0) { ret = TRUE; } @@ -997,7 +997,7 @@ rspamd_task_log_check_condition (struct rspamd_task *task, break; case RSPAMD_LOG_MIME_RCPT: case RSPAMD_LOG_MIME_RCPTS: - if (MESSAGE_FIELD (task, rcpt_mime) && + if (MESSAGE_FIELD_CHECK (task, rcpt_mime) && MESSAGE_FIELD (task, rcpt_mime)->len > 0) { ret = TRUE; } @@ -1008,7 +1008,7 @@ rspamd_task_log_check_condition (struct rspamd_task *task, } break; case RSPAMD_LOG_MIME_FROM: - if (MESSAGE_FIELD (task, from_mime) && + if (MESSAGE_FIELD_CHECK (task, from_mime) && MESSAGE_FIELD (task, from_mime)->len > 0) { ret = TRUE; } @@ -1328,7 +1328,7 @@ rspamd_task_log_variable (struct rspamd_task *task, switch (lf->type) { /* String vars */ case RSPAMD_LOG_MID: - if (MESSAGE_FIELD (task, message_id)) { + if (MESSAGE_FIELD_CHECK (task, message_id)) { var.begin = MESSAGE_FIELD (task, message_id); var.len = strlen (var.begin); } @@ -1398,7 +1398,7 @@ rspamd_task_log_variable (struct rspamd_task *task, } break; case RSPAMD_LOG_MIME_FROM: - if (MESSAGE_FIELD (task, from_mime)) { + if (MESSAGE_FIELD_CHECK (task, from_mime)) { return rspamd_task_write_ialist (task, MESSAGE_FIELD (task, from_mime), 1, @@ -1413,7 +1413,7 @@ rspamd_task_log_variable (struct rspamd_task *task, } break; case RSPAMD_LOG_MIME_RCPT: - if (MESSAGE_FIELD (task, rcpt_mime)) { + if (MESSAGE_FIELD_CHECK (task, rcpt_mime)) { return rspamd_task_write_ialist (task, MESSAGE_FIELD (task, rcpt_mime), 1, @@ -1428,7 +1428,7 @@ rspamd_task_log_variable (struct rspamd_task *task, } break; case RSPAMD_LOG_MIME_RCPTS: - if (MESSAGE_FIELD (task, rcpt_mime)) { + if (MESSAGE_FIELD_CHECK (task, rcpt_mime)) { return rspamd_task_write_ialist (task, MESSAGE_FIELD (task, rcpt_mime), -1, /* All addresses */ @@ -1437,10 +1437,16 @@ rspamd_task_log_variable (struct rspamd_task *task, } break; case RSPAMD_LOG_DIGEST: - var.len = rspamd_snprintf (numbuf, sizeof (numbuf), "%*xs", - (gint)sizeof (MESSAGE_FIELD (task, digest)), - MESSAGE_FIELD (task, digest)); - var.begin = numbuf; + if (task->message) { + var.len = rspamd_snprintf (numbuf, sizeof (numbuf), "%*xs", + (gint) sizeof (MESSAGE_FIELD (task, digest)), + MESSAGE_FIELD (task, digest)); + var.begin = numbuf; + } + else { + var.begin = undef; + var.len = sizeof (undef) - 1; + } break; case RSPAMD_LOG_FILENAME: if (task->msg.fpath) { |