From e743ce7053bdeb0b15220f7d842eb48d6721e48b Mon Sep 17 00:00:00 2001 From: =?utf8?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 6a194e7f9f1..645bd7b4cf3 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 1f88ee9562e..494ee71e951 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 zc-rk(VN=^i5bbCE3KG(!&NTI%bkg0GDig;TP>U@`5}lF?6x~TzNP%Pw83dW(w|Ccz zXVMwkl4;2J10HOSy?1+O-Fy3%sv7QOd78ziaipTaNBGa`(bkxVG1bffB~4sE!0 z7zeEm_?n5G5RsBx@-SqANnspdb?cbq%GEkpJC3mWb@igXw3C=kDgp4a0cvUq{CuxyRlHsQ?83sDyfYu@Rs+Vb6RLS~(9>uGQY%s~E zX;#Fi7pF(>{_v(*l4eP<8wXy#n{TI^)y80$Y-1!^M3VKs{!b=FdSMULw8ctKKfKwRAtsQ00WDaVe}XO~jQ~ZKZiJ8H`8q!MoG5llr(_JlQEM_e1H! z9ey&*)17QM`geK=6@)zU)(6EPW?%T_0qaN!_guK=LUs35Q9)G{u3@2t-TwAff4`|J zid$4ge+jDM5s(F`DfWp<99d>wlrvx?{>f1V!1I>v1>@64WhWhrNDvLMlld3O$`|Dc z$$$Y~1;osj^^o7dNcHqNrL#UtOC=cu!vl&LfO1G_7HYsfoqbEPa4^f@txfMeOyNoF z7KswWN`FMHJ|S81hJA?@i zDf+{M@3C=l^I-XyI9y8-Mk}8|ylm%H*eP@hNa!T?R=be3<%C17qD6qXX4h>C(%%BG zY09&oFDUz>;Q@#%5IJv>u8Tb8aP1Qu9HX{Yu_Z${I42it?GV6@HbjZKhI%n$Y1{_q z{!*$!->iy`VXw)04cHy_fY>5he}IO2|9{wh?~TN|le?OgXDet}YLb{KdgF)3{ zL3Y)k;OCd&<7Ir;BcSt1d&YjaqD#;cb$*5Sc;!>0hrOl2tavkWe+4N){UGx{l64x~ z5PcL~6?I_hN0c3Rk&cLfj)>J_zAIiA>n}1td;_0~NMWLLJk^wBgbvQIB(PN?2FGup Oma#Gb_VfKxd){B}R6!X4 literal 0 Hc-jL100001 -- 2.47.3