summaryrefslogtreecommitdiff
path: root/src/basic/journal-importer.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-05-17 11:09:07 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-05-31 14:30:08 +0200
commitcca24fc3e60680861b1783dd54e80da7d16db347 (patch)
tree9813072caafde1c0f1dbfe6e2b94b765dbe51e1e /src/basic/journal-importer.c
parent8409f688589c41ac30a1d67f41b3ffab6ae175d3 (diff)
downloadsystemd-cca24fc3e60680861b1783dd54e80da7d16db347.tar.gz
basic/journal-importer: escape & ellipsize bad data in log entries
We shouldn't just log arbitrary stuff, in particular newlines and control chars Now: Unknown dunder line __CURSORFACILITY=6\nSYSLOG_IDENTIFIER=/USR/SBIN/CRON\nMES…, ignoring. Unknown dunder line __REALTIME_TIME[TAMP=1404101101501874\n__MONOTONIC_TIMEST…, ignoring.
Diffstat (limited to 'src/basic/journal-importer.c')
-rw-r--r--src/basic/journal-importer.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/basic/journal-importer.c b/src/basic/journal-importer.c
index 81044b85fb..1d5f84af4d 100644
--- a/src/basic/journal-importer.c
+++ b/src/basic/journal-importer.c
@@ -247,6 +247,7 @@ static int get_data_newline(JournalImporter *imp) {
static int process_dunder(JournalImporter *imp, char *line, size_t n) {
const char *timestamp;
+ char buf[CELLESCAPE_DEFAULT_LENGTH];
int r;
assert(line);
@@ -264,10 +265,12 @@ static int process_dunder(JournalImporter *imp, char *line, size_t n) {
timestamp = startswith(line, "__REALTIME_TIMESTAMP=");
if (timestamp) {
uint64_t x;
+
line[n-1] = '\0';
r = safe_atou64(timestamp, &x);
if (r < 0)
- return log_warning_errno(r, "Failed to parse __REALTIME_TIMESTAMP '%s': %m", timestamp);
+ return log_warning_errno(r, "Failed to parse __REALTIME_TIMESTAMP '%s': %m",
+ cellescape(buf, sizeof buf, timestamp));
else if (!VALID_REALTIME(x)) {
log_warning("__REALTIME_TIMESTAMP out of range, ignoring: %"PRIu64, x);
return -ERANGE;
@@ -280,10 +283,12 @@ static int process_dunder(JournalImporter *imp, char *line, size_t n) {
timestamp = startswith(line, "__MONOTONIC_TIMESTAMP=");
if (timestamp) {
uint64_t x;
+
line[n-1] = '\0';
r = safe_atou64(timestamp, &x);
if (r < 0)
- return log_warning_errno(r, "Failed to parse __MONOTONIC_TIMESTAMP '%s': %m", timestamp);
+ return log_warning_errno(r, "Failed to parse __MONOTONIC_TIMESTAMP '%s': %m",
+ cellescape(buf, sizeof buf, timestamp));
else if (!VALID_MONOTONIC(x)) {
log_warning("__MONOTONIC_TIMESTAMP out of range, ignoring: %"PRIu64, x);
return -ERANGE;
@@ -295,7 +300,7 @@ static int process_dunder(JournalImporter *imp, char *line, size_t n) {
timestamp = startswith(line, "__");
if (timestamp) {
- log_notice("Unknown dunder line %s, ignoring.", line);
+ log_notice("Unknown dunder line __%s, ignoring.", cellescape(buf, sizeof buf, timestamp));
return 1;
}