summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-05-17 09:27:30 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-05-31 13:04:18 +0200
commite743ce7053bdeb0b15220f7d842eb48d6721e48b (patch)
tree2eae1adbfa233d1c61ac441408af1b8da6af2942
parent41b0b1274d34db1605fb78c1c82e420d7e742f6e (diff)
downloadsystemd-e743ce7053bdeb0b15220f7d842eb48d6721e48b.tar.gz
journal-remote: when an entry is rejected with -EBADMSG, do not rotate the journal file
Something is wrong with the entry (probably a missing timestamp), so no point in rotating. But suppress the error in process_source(), so that the processing of the data stream continues. Also, just return 0 from writer_write() on success, the only caller doesn't care.
-rw-r--r--src/journal-remote/journal-remote-parse.c6
-rw-r--r--src/journal-remote/journal-remote-write.c7
-rw-r--r--test/fuzz-corpus/journal-remote/invalid-ts.txtbin0 -> 4657 bytes
3 files changed, 8 insertions, 5 deletions
diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c
index 6a194e7f9f..645bd7b4cf 100644
--- a/src/journal-remote/journal-remote-parse.c
+++ b/src/journal-remote/journal-remote-parse.c
@@ -32,7 +32,6 @@ void source_free(RemoteSource *source) {
* ownership of fd, name, and writer, otherwise does not touch them.
*/
RemoteSource* source_new(int fd, bool passive_fd, char *name, Writer *writer) {
-
RemoteSource *source;
log_debug("Creating source for %sfd:%d (%s)",
@@ -75,7 +74,10 @@ int process_source(RemoteSource *source, bool compress, bool seal) {
assert(source->importer.iovw.iovec);
r = writer_write(source->writer, &source->importer.iovw, &source->importer.ts, compress, seal);
- if (r < 0)
+ if (r == -EBADMSG) {
+ log_error_errno(r, "Entry is invalid, ignoring.");
+ r = 0;
+ } else if (r < 0)
log_error_errno(r, "Failed to write entry of %zu bytes: %m",
iovw_size(&source->importer.iovw));
else
diff --git a/src/journal-remote/journal-remote-write.c b/src/journal-remote/journal-remote-write.c
index 1f88ee9562..494ee71e95 100644
--- a/src/journal-remote/journal-remote-write.c
+++ b/src/journal-remote/journal-remote-write.c
@@ -97,8 +97,9 @@ int writer_write(Writer *w,
if (r >= 0) {
if (w->server)
w->server->event_count += 1;
- return 1;
- }
+ return 0;
+ } else if (r == -EBADMSG)
+ return r;
log_debug_errno(r, "%s: Write failed, rotating: %m", w->journal->path);
r = do_rotate(&w->journal, compress, seal);
@@ -115,5 +116,5 @@ int writer_write(Writer *w,
if (w->server)
w->server->event_count += 1;
- return 1;
+ return 0;
}
diff --git a/test/fuzz-corpus/journal-remote/invalid-ts.txt b/test/fuzz-corpus/journal-remote/invalid-ts.txt
new file mode 100644
index 0000000000..bc036fdcb0
--- /dev/null
+++ b/test/fuzz-corpus/journal-remote/invalid-ts.txt
Binary files differ