From 2010c02e5c3c70880a53cb0403ce696708f4d590 Mon Sep 17 00:00:00 2001 From: Philip Prindeville Date: Fri, 11 Aug 2017 12:30:50 -0600 Subject: Add syslog.filter INI for filtering syslog messages Signed-off-by: Philip Prindeville --- main/php_syslog.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'main/php_syslog.c') diff --git a/main/php_syslog.c b/main/php_syslog.c index 7fcecef231..3bb9ee86dd 100644 --- a/main/php_syslog.c +++ b/main/php_syslog.c @@ -86,11 +86,23 @@ PHPAPI void php_syslog(int priority, const char *format, ...) /* {{{ */ break; } - if (c != '\n') + /* check for NVT ASCII only unless test disabled */ + if (((0x20 <= c) && (c <= 0x7e))) smart_string_appendc(&sbuf, c); - else { + else if ((c >= 0x80) && (PG(syslog_filter) != PHP_SYSLOG_FILTER_ASCII)) + smart_string_appendc(&sbuf, c); + else if (c == '\n') { syslog(priority, "%.*s", (int)sbuf.len, sbuf.c); smart_string_reset(&sbuf); + } else if ((c < 0x20) && (PG(syslog_filter) == PHP_SYSLOG_FILTER_NONE)) + smart_string_appendc(&sbuf, c); + else { + const char xdigits[] = "0123456789abcdef"; + + smart_string_appendl(&sbuf, "\\x", 2); + smart_string_appendc(&sbuf, xdigits[(c / 0x10)]); + c &= 0x0f; + smart_string_appendc(&sbuf, xdigits[c]); } } -- cgit v1.2.1