From: Vsevolod Stakhov Date: Tue, 25 Oct 2011 17:20:49 +0000 (+0400) Subject: Do not try to validate empty headers. X-Git-Tag: 0.4.5~41 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2e15cacc80101d91108be8aaa4ea722f31d22d6b;p=rspamd.git Do not try to validate empty headers. Write symbols to log in case of HTTP/Json output. --- diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index e4eb82398..77c67015c 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -698,7 +698,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const gchar /* Try to match regexp */ if (!re->is_raw) { /* Validate input */ - if (!g_utf8_validate (cur->data, -1, NULL)) { + if (!cur->data || !g_utf8_validate (cur->data, -1, NULL)) { cur = g_list_next (cur); continue; } @@ -923,7 +923,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const gchar /* Try to match regexp */ if (!re->is_raw) { /* Validate input */ - if (!g_utf8_validate (rh->value, -1, NULL)) { + if (!rh->value || !g_utf8_validate (rh->value, -1, NULL)) { cur = g_list_next (cur); continue; } diff --git a/src/protocol.c b/src/protocol.c index 8d72420a1..73f8b9de6 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -898,6 +898,8 @@ metric_symbols_callback_json (gpointer key, gpointer value, void *user_data) } cd->symbols_offset += rspamd_snprintf (cd->symbols_buf + cd->symbols_offset, cd->symbols_size - cd->symbols_offset, " },"); + cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, + "%s,", (gchar *)key); } /* * Print a single symbol using json protocol @@ -917,6 +919,10 @@ show_metric_symbols_json (struct metric_result *metric_res, struct metric_callba g_hash_table_foreach (h, metric_symbols_callback_json, cd); g_hash_table_unref (h); if (cd->alive) { + /* Remove last , from log buf */ + if (cd->log_buf[cd->log_offset - 1] == ',') { + cd->log_buf[--cd->log_offset] = '\0'; + } /* Remove last ',' symbol */ if (cd->symbols_buf[cd->symbols_offset - 1] == ',') { cd->symbols_buf[--cd->symbols_offset] = '\0';