diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-05-20 22:51:28 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-05-31 14:30:23 +0200 |
commit | bcac9822378953e2b5d615e7efba83e9ed474eab (patch) | |
tree | fe1a402f793bfcda150f67345faa9e751d38956f | |
parent | 1e448731f51865184ba988b246d02823a9284d6c (diff) | |
download | systemd-bcac9822378953e2b5d615e7efba83e9ed474eab.tar.gz |
basic/journal-importer: "trusted" fields in binary format are not supported
The parser never accepted "__"-prefixed fields in binary format, but there was
a comment questioning this decision. Let's make it official, and remove the
comment.
Also, for clarity, let's move the dunder field parsing after the field
verification check. This doesn't change much, because invalid fields cannot be
known special fields, but is seems cleaner to first verify the validity of the
name, and then check if it is one of the known ones.
-rw-r--r-- | src/basic/journal-importer.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/basic/journal-importer.c b/src/basic/journal-importer.c index 86aa834525..a751c5ec8a 100644 --- a/src/basic/journal-importer.c +++ b/src/basic/journal-importer.c @@ -246,17 +246,12 @@ static int get_data_newline(JournalImporter *imp) { return 1; } -static int process_dunder(JournalImporter *imp, char *line, size_t n) { +static int process_dunder(JournalImporter *imp, char *line) { const char *timestamp; char buf[CELLESCAPE_DEFAULT_LENGTH]; int r; assert(line); - assert(n > 0); - assert(line[n-1] == '\n'); - - /* XXX: is it worth to support timestamps in extended format? - * We don't produce them, but who knows... */ timestamp = startswith(line, "__CURSOR="); if (timestamp) @@ -267,7 +262,6 @@ static int process_dunder(JournalImporter *imp, char *line, size_t n) { 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", @@ -285,7 +279,6 @@ static int process_dunder(JournalImporter *imp, char *line, size_t n) { 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", @@ -334,10 +327,6 @@ int journal_importer_process_data(JournalImporter *imp) { return 1; } - r = process_dunder(imp, line, n); - if (r != 0) - return r < 0 ? r : 0; - /* MESSAGE=xxx\n or COREDUMP\n @@ -358,6 +347,11 @@ int journal_importer_process_data(JournalImporter *imp) { return 0; } + line[n] = '\0'; + r = process_dunder(imp, line); + if (r != 0) + return r < 0 ? r : 0; + r = iovw_put(&imp->iovw, line, n); if (r < 0) return r; |