]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-journal-flush: do not croak on corrupted input files 21529/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 26 Nov 2021 08:46:02 +0000 (09:46 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 26 Nov 2021 08:48:15 +0000 (09:48 +0100)
We would fail if the input file was corrupted:
build/test-journal-flush ./system@0005b7dac334f805-0021aca076ae5c5e.journal\~
journal_file_copy_entry failed: Bad message
Assertion 'r >= 0' failed at src/libsystemd/sd-journal/test-journal-flush.c:55, function main(). Aborting.
[1]    619472 IOT instruction (core dumped)  build/test-journal-flush ./system@0005b7dac334f805-0021aca076ae5c5e.journal\~

Let's skip some "reasonable" errors.

Fixes #17963.

src/libsystemd/sd-journal/test-journal-flush.c

index aa814225dda81dd25bf219e77dfa38a4c278e0ce..c6fb65791e9147a49a4c1f5cca77a2a5ae732f69 100644 (file)
@@ -51,8 +51,11 @@ int main(int argc, char *argv[]) {
 
                 r = journal_file_copy_entry(f, new_journal, o, f->current_offset);
                 if (r < 0)
-                        log_error_errno(r, "journal_file_copy_entry failed: %m");
-                assert_se(r >= 0);
+                        log_warning_errno(r, "journal_file_copy_entry failed: %m");
+                assert_se(r >= 0 ||
+                          IN_SET(r, -EBADMSG,         /* corrupted file */
+                                    -EPROTONOSUPPORT, /* unsupported compression */
+                                    -EIO));           /* file rotated */
 
                 if (++n >= 10000)
                         break;