diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-11-16 22:00:29 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-11-16 22:00:29 +0300 |
commit | 3ebceeece2204d3755df1f1cc8210f7e97b6daad (patch) | |
tree | 38c122341dbbb2f1ea1a4c969ad95dda38c1106e /src/logger.c | |
parent | c85dd608a568d61e3b24c55b715ad37ceedb7110 (diff) | |
download | rspamd-3ebceeece2204d3755df1f1cc8210f7e97b6daad.tar.gz rspamd-3ebceeece2204d3755df1f1cc8210f7e97b6daad.zip |
Make own strlcpy that does not calculate remaining string length (faster and more safe)
Allow only ASCII symbols in logs, escape control chars
Diffstat (limited to 'src/logger.c')
-rw-r--r-- | src/logger.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/logger.c b/src/logger.c index 01e0210ec..87217fb87 100644 --- a/src/logger.c +++ b/src/logger.c @@ -318,7 +318,7 @@ flush_log_buf (void) void rspamd_common_log_function (GLogLevelFlags log_level, const gchar *function, const gchar *fmt, ...) { - static gchar logbuf[BUFSIZ]; + static gchar logbuf[BUFSIZ], escaped_logbuf[BUFSIZ]; va_list vp; u_char *end; @@ -326,8 +326,9 @@ rspamd_common_log_function (GLogLevelFlags log_level, const gchar *function, con va_start (vp, fmt); end = rspamd_vsnprintf (logbuf, sizeof (logbuf), fmt, vp); *end = '\0'; + (void)rspamd_escape_string (escaped_logbuf, logbuf, sizeof (escaped_logbuf)); va_end (vp); - rspamd_log->log_func (NULL, function, log_level, logbuf, FALSE, rspamd_log->cfg); + rspamd_log->log_func (NULL, function, log_level, escaped_logbuf, FALSE, rspamd_log->cfg); } } @@ -550,7 +551,7 @@ file_log_function (const gchar * log_domain, const gchar *function, GLogLevelFla void rspamd_conditional_debug (guint32 addr, const gchar *function, const gchar *fmt, ...) { - static gchar logbuf[BUFSIZ]; + static gchar logbuf[BUFSIZ], escaped_logbuf[BUFSIZ]; va_list vp; u_char *end; @@ -560,16 +561,20 @@ rspamd_conditional_debug (guint32 addr, const gchar *function, const gchar *fmt, va_start (vp, fmt); end = rspamd_vsnprintf (logbuf, sizeof (logbuf), fmt, vp); *end = '\0'; + (void)rspamd_escape_string (escaped_logbuf, logbuf, sizeof (escaped_logbuf)); va_end (vp); - rspamd_log->log_func (NULL, function, G_LOG_LEVEL_DEBUG, logbuf, TRUE, rspamd_log->cfg); + rspamd_log->log_func (NULL, function, G_LOG_LEVEL_DEBUG, escaped_logbuf, TRUE, rspamd_log->cfg); } } void rspamd_glib_log_function (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer arg) { + gchar escaped_logbuf[BUFSIZ]; + if (rspamd_log->enabled) { - rspamd_log->log_func (log_domain, NULL, log_level, message, FALSE, rspamd_log->cfg); + (void)rspamd_escape_string (escaped_logbuf, message, sizeof (escaped_logbuf)); + rspamd_log->log_func (log_domain, NULL, log_level, escaped_logbuf, FALSE, rspamd_log->cfg); } } |