summaryrefslogtreecommitdiff
path: root/src/journal-remote
diff options
context:
space:
mode:
authorEvgeny Vereshchagin <evvers@ya.ru>2022-01-20 13:41:56 +0000
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-01-21 04:20:47 +0900
commit381ccb5cc002dca7d0f3c2ac418b63ff265eefa6 (patch)
tree6e9c972e5ad66f6d0448fab943957068b5f6c5ae /src/journal-remote
parent478c632e00ffbf50012b1946a8a025494c012353 (diff)
downloadsystemd-381ccb5cc002dca7d0f3c2ac418b63ff265eefa6.tar.gz
tests: make fuzz-journal-remote less flaky
by always calling journal_remote_server_destroy, which resets global variables like journal_remote_server_global. It should prevent crashes like ``` Assertion 'journal_remote_server_global == NULL' failed at src/journal-remote/journal-remote.c:312, function int journal_remote_server_init(RemoteServer *, const char *, JournalWriteSplitMode, _Bool, _Bool)(). Aborting. AddressSanitizer:DEADLYSIGNAL ================================================================= ==24769==ERROR: AddressSanitizer: ABRT on unknown address 0x0539000060c1 (pc 0x7f23b4d5818b bp 0x7ffcbc4080c0 sp 0x7ffcbc407e70 T0) SCARINESS: 10 (signal) #0 0x7f23b4d5818b in raise /build/glibc-eX1tMB/glibc-2.31/sysdeps/unix/sysv/linux/raise.c:51:1 #1 0x7f23b4d37858 in abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:79:7 #2 0x7f23b5731809 in log_assert_failed systemd/src/basic/log.c:866:9 ```
Diffstat (limited to 'src/journal-remote')
-rw-r--r--src/journal-remote/fuzz-journal-remote.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/journal-remote/fuzz-journal-remote.c b/src/journal-remote/fuzz-journal-remote.c
index 32c4e1819c..1731b94bb8 100644
--- a/src/journal-remote/fuzz-journal-remote.c
+++ b/src/journal-remote/fuzz-journal-remote.c
@@ -21,7 +21,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_(unlink_tempfilep) char name[] = "/tmp/fuzz-journal-remote.XXXXXX.journal";
_cleanup_close_ int fdout = -1;
_cleanup_(sd_journal_closep) sd_journal *j = NULL;
- RemoteServer s = {};
+ _cleanup_(journal_remote_server_destroy) RemoteServer s = {};
int r;
if (size <= 2)
@@ -59,7 +59,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
while (s.active)
assert_se(journal_remote_handle_raw_source(NULL, fdin, 0, &s) >= 0);
- journal_remote_server_destroy(&s);
assert_se(close(fdin) < 0 && errno == EBADF); /* Check that the fd is closed already */
/* Out */