diff options
author | Philip Prindeville <philipp@redfish-solutions.com> | 2017-08-11 12:30:50 -0600 |
---|---|---|
committer | Jakub Zelenka <bukka@php.net> | 2018-07-22 15:36:47 +0100 |
commit | 2010c02e5c3c70880a53cb0403ce696708f4d590 (patch) | |
tree | 0593b22f3470a7082b5fbd7bbba4228cd2177b4a /main/php_syslog.c | |
parent | 4a528d46f52f9d3bbb3b8f2191689d4aadca82ba (diff) | |
download | php-git-2010c02e5c3c70880a53cb0403ce696708f4d590.tar.gz |
Add syslog.filter INI for filtering syslog messages
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Diffstat (limited to 'main/php_syslog.c')
-rw-r--r-- | main/php_syslog.c | 16 |
1 files changed, 14 insertions, 2 deletions
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]); } } |