char cont = '-';
size_t len;
ssize_t ret;
+ const int prime = (log_b == &log_buf);
p = user->buf;
e = user->buf + sizeof(user->buf);
for (i = 0; i < msg->text_len; i++) {
unsigned char c = log_text(msg)[i];
- append_char(&p, e, c);
+ if (prime && (c < ' ' || c >= 127 || c == '\\'))
+ p += scnprintf(p, e - p, "\\x%02x", c);
+ else
+ append_char(&p, e, c);
}
/*
* to security: else one could forge dictionary tags through the message
* such as "text\n _PID=123"
*/
- append_char(&p, e, '\0');
+ if (!prime)
+ append_char(&p, e, '\0');
append_char(&p, e, '\n');
if (msg->dict_len) {
continue;
}
+ if (prime && (c < ' ' || c >= 127 || c == '\\')) {
+ p += scnprintf(p, e - p, "\\x%02x", c);
+ continue;
+ }
+
append_char(&p, e, c);
}
append_char(&p, e, '\n');