aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-10-25 21:20:49 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-10-25 21:20:49 +0400
commit2e15cacc80101d91108be8aaa4ea722f31d22d6b (patch)
tree1bed5d6b92159cf3f5421307b7c7ae096475cc29 /src
parent88f4ea9a5b1e55169fa23ad2b7ffe7985fb8c3ed (diff)
downloadrspamd-2e15cacc80101d91108be8aaa4ea722f31d22d6b.tar.gz
rspamd-2e15cacc80101d91108be8aaa4ea722f31d22d6b.zip
Do not try to validate empty headers.
Write symbols to log in case of HTTP/Json output.
Diffstat (limited to 'src')
-rw-r--r--src/plugins/regexp.c4
-rw-r--r--src/protocol.c6
2 files changed, 8 insertions, 2 deletions
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';