From e743ce7053bdeb0b15220f7d842eb48d6721e48b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 17 May 2018 09:27:30 +0200 Subject: [PATCH] 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. --- src/journal-remote/journal-remote-parse.c | 6 ++++-- src/journal-remote/journal-remote-write.c | 7 ++++--- test/fuzz-corpus/journal-remote/invalid-ts.txt | Bin 0 -> 4657 bytes 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 test/fuzz-corpus/journal-remote/invalid-ts.txt 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 0000000000000000000000000000000000000000..bc036fdcb01a9e4d6a89ead179a91d2507c759ef GIT binary patch literal 4657 zcmeHKVRPIx5aqLfMbnf*IzS{_wj_d?UN4u#kUOWg!;s>}Sh7S?nzWNkr*4?(Z|Ch@ zZYVPWQphp+kejnlUOnw8{2r} zIE|c+_=ZWn5Q&mp@;GLKNnt#&+Ic3q@~w_GPExK_!Xm@NPHvp1YoE+NO)(nmR@r#e z(5a+WGuiLtJ?Q;y+*?!#{R{j{*rw1^aD21eTzU|Wk>KAVPyz^Ca2)t_i%|7tq>ZJ z2+=eadW%h3SS-i9U&PngKo?)Y?4RO>pa%1_H7BqO1K%1RxCxqlykHhI+w-6CV7QY_ zM)cMb%|mWm!8;yWZW7%}oiHwi4W&uA3Ywj~tR{o;C_Q>LJwI(v+~UpdVR;zK5dYx^ z!!qA5hNHhv522!%C&A{R8l>!oKLN6C&V;*MxXXn_E-XQ(4_a{~S=_*we z*HFdq7O3J&2nWfOIGoE0C&e?5>ocemREFc~T4+9h8cN?||2j z>r+4=MhtibK_ZoMYz?;#>ZBf#8e+2;fA}sOGV>d?3uyS`k-(jJOo_>7~oejrYqj!!kh?g2#bPFkf1yD8 zaTG|dK>_?pH$j2_*dnWTi^O*uNh*M1Wl2$E<~=^tS+ZU48x?3JQ6r{Kj%hd|wfA z)-Yd+Jo)ers;~74mWoxZ0p*l_OS{ApJH*DYPYOsB^_Zo;+<+J~cF|i@-&@EEeKjk3 z2EuE$)}h?dd4P@!HXPus+?~Vj&SA52*iz2SXZ86#Dp;U4b#fgjM6F-TQJ~tm0=ZCi zKwA(M0|#|b=5w@t1oU_!?iu^$J!fE*SDFe>mAAgY6LGU~7R6!X4 literal 0 HcmV?d00001