aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-06 15:37:45 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-06 15:37:45 +0000
commit32edc7767d567f6882418b77781ee04d7faa86aa (patch)
tree3158ceee5d86c37581f3caf68c51b80da56b322a
parentf0a01474f33b7007480371e303883e00f48e9d9f (diff)
downloadrspamd-32edc7767d567f6882418b77781ee04d7faa86aa.tar.gz
rspamd-32edc7767d567f6882418b77781ee04d7faa86aa.zip
Replace '\n' with space in log_format
-rw-r--r--src/libserver/cfg_utils.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index a96f39e5f..0a0926b6e 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -403,7 +403,8 @@ rspamd_config_process_var (struct rspamd_config *cfg, const rspamd_ftok_t *var,
static gboolean
rspamd_config_parse_log_format (struct rspamd_config *cfg)
{
- const gchar *p, *c, *end;
+ const gchar *p, *c, *end, *s;
+ gchar *d;
struct rspamd_log_format *lf = NULL;
rspamd_ftok_t var, var_content;
enum {
@@ -439,8 +440,22 @@ rspamd_config_parse_log_format (struct rspamd_config *cfg)
lf = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (*lf));
lf->type = RSPAMD_LOG_STRING;
lf->data = rspamd_mempool_alloc (cfg->cfg_pool, p - c + 1);
- lf->len = p - c;
- rspamd_strlcpy (lf->data, c, p - c + 1);
+ /* Filter \r\n from the destination */
+ s = c;
+ d = lf->data;
+
+ while (s < p) {
+ if (*s != '\r' && *s != '\n') {
+ *d++ = *s++;
+ }
+ else {
+ *d ++ = ' ';
+ s++;
+ }
+ }
+ *d = '\0';
+
+ lf->len = d - (char *) lf->data;
DL_APPEND (cfg->log_format, lf);
lf = NULL;
}
@@ -500,8 +515,22 @@ rspamd_config_parse_log_format (struct rspamd_config *cfg)
lf = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (*lf));
lf->type = RSPAMD_LOG_STRING;
lf->data = rspamd_mempool_alloc (cfg->cfg_pool, p - c + 1);
- lf->len = p - c;
- rspamd_strlcpy (lf->data, c, p - c + 1);
+ /* Filter \r\n from the destination */
+ s = c;
+ d = lf->data;
+
+ while (s < p) {
+ if (*s != '\r' && *s != '\n') {
+ *d++ = *s++;
+ }
+ else {
+ *d++ = ' ';
+ s++;
+ }
+ }
+ *d = '\0';
+
+ lf->len = d - (char *)lf->data;
DL_APPEND (cfg->log_format, lf);
lf = NULL;
}