summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/fuzz-execute-serialize.c7
-rw-r--r--src/core/fuzz-manager-serialize.c7
-rw-r--r--src/core/fuzz-unit-file.c5
-rw-r--r--src/fuzz/fuzz-bootspec.c4
-rw-r--r--src/fuzz/fuzz-bus-label.c2
-rw-r--r--src/fuzz/fuzz-calendarspec.c3
-rw-r--r--src/fuzz/fuzz-catalog.c3
-rw-r--r--src/fuzz/fuzz-compress.c5
-rw-r--r--src/fuzz/fuzz-env-file.c5
-rw-r--r--src/fuzz/fuzz-hostname-setup.c5
-rw-r--r--src/fuzz/fuzz-json.c4
-rw-r--r--src/fuzz/fuzz-time-util.c3
-rw-r--r--src/fuzz/fuzz-udev-database.c3
-rw-r--r--src/fuzz/fuzz-varlink-idl.c4
-rw-r--r--src/fuzz/fuzz-varlink.c3
-rw-r--r--src/fuzz/fuzz.h8
-rw-r--r--src/journal-remote/fuzz-journal-remote.c3
-rw-r--r--src/journal/fuzz-journald-audit.c2
-rw-r--r--src/journal/fuzz-journald-kmsg.c5
-rw-r--r--src/journal/fuzz-journald-native-fd.c3
-rw-r--r--src/journal/fuzz-journald-native.c2
-rw-r--r--src/journal/fuzz-journald-stream.c3
-rw-r--r--src/journal/fuzz-journald-syslog.c2
-rw-r--r--src/libsystemd-network/fuzz-dhcp-client.c3
-rw-r--r--src/libsystemd-network/fuzz-dhcp-server-relay.c2
-rw-r--r--src/libsystemd-network/fuzz-dhcp-server.c2
-rw-r--r--src/libsystemd-network/fuzz-dhcp6-client.c3
-rw-r--r--src/libsystemd-network/fuzz-lldp-rx.c2
-rw-r--r--src/libsystemd-network/fuzz-ndisc-rs.c2
-rw-r--r--src/libsystemd/sd-bus/fuzz-bus-match.c5
-rw-r--r--src/libsystemd/sd-bus/fuzz-bus-message.c5
-rw-r--r--src/network/fuzz-netdev-parser.c3
-rw-r--r--src/network/fuzz-network-parser.c3
-rw-r--r--src/nspawn/fuzz-nspawn-oci.c5
-rw-r--r--src/nspawn/fuzz-nspawn-settings.c5
-rw-r--r--src/resolve/fuzz-dns-packet.c2
-rw-r--r--src/resolve/fuzz-etc-hosts.c3
-rw-r--r--src/resolve/fuzz-resource-record.c2
-rw-r--r--src/systemctl/fuzz-systemctl-parse-argv.c5
-rw-r--r--src/udev/fido_id/fuzz-fido-id-desc.c5
-rw-r--r--src/udev/fuzz-udev-rules.c3
-rw-r--r--src/udev/net/fuzz-link-parser.c3
-rw-r--r--src/xdg-autostart-generator/fuzz-xdg-desktop.c5
43 files changed, 60 insertions, 99 deletions
diff --git a/src/core/fuzz-execute-serialize.c b/src/core/fuzz-execute-serialize.c
index 140b2b8250..a62a135fdf 100644
--- a/src/core/fuzz-execute-serialize.c
+++ b/src/core/fuzz-execute-serialize.c
@@ -82,12 +82,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_fdset_free_ FDSet *fdset = NULL;
- /* We don't want to fill the logs with messages about parse errors.
- * Disable most logging if not running standalone. */
- if (!getenv("SYSTEMD_LOG_LEVEL")) {
- log_set_max_level(LOG_CRIT);
- log_set_target(LOG_TARGET_NULL);
- }
+ fuzz_setup_logging();
assert_se(fdset = fdset_new());
assert_se(f = data_to_file(data, size));
diff --git a/src/core/fuzz-manager-serialize.c b/src/core/fuzz-manager-serialize.c
index 0e4bfa4484..57083ca25f 100644
--- a/src/core/fuzz-manager-serialize.c
+++ b/src/core/fuzz-manager-serialize.c
@@ -17,12 +17,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (outside_size_range(size, 0, 65536))
return 0;
- /* We don't want to fill the logs with messages about parse errors.
- * Disable most logging if not running standalone. */
- if (!getenv("SYSTEMD_LOG_LEVEL")) {
- log_set_max_level(LOG_CRIT);
- log_set_target(LOG_TARGET_NULL);
- }
+ fuzz_setup_logging();
assert_se(manager_new(RUNTIME_SCOPE_SYSTEM, MANAGER_TEST_RUN_MINIMAL|MANAGER_TEST_DONT_OPEN_EXECUTOR, &m) >= 0);
/* Set log overrides as well to make it harder for a serialization file
diff --git a/src/core/fuzz-unit-file.c b/src/core/fuzz-unit-file.c
index 7b738062b5..57480cf766 100644
--- a/src/core/fuzz-unit-file.c
+++ b/src/core/fuzz-unit-file.c
@@ -60,10 +60,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
assert_se(fseek(f, offset, SEEK_SET) == 0);
- /* We don't want to fill the logs with messages about parse errors.
- * Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
assert_se(manager_new(RUNTIME_SCOPE_SYSTEM, MANAGER_TEST_RUN_MINIMAL|MANAGER_TEST_DONT_OPEN_EXECUTOR, &m) >= 0);
diff --git a/src/fuzz/fuzz-bootspec.c b/src/fuzz/fuzz-bootspec.c
index cea674c4c8..7a85787764 100644
--- a/src/fuzz/fuzz-bootspec.c
+++ b/src/fuzz/fuzz-bootspec.c
@@ -87,9 +87,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (outside_size_range(size, 0, 65536))
return 0;
- /* Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
assert_se(datadup = memdup_suffix0(data, size));
diff --git a/src/fuzz/fuzz-bus-label.c b/src/fuzz/fuzz-bus-label.c
index 93bac9adf4..c7be82a767 100644
--- a/src/fuzz/fuzz-bus-label.c
+++ b/src/fuzz/fuzz-bus-label.c
@@ -9,6 +9,8 @@
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_free_ char *unescaped = NULL, *escaped = NULL;
+ fuzz_setup_logging();
+
unescaped = bus_label_unescape_n((const char*)data, size);
assert_se(unescaped != NULL);
escaped = bus_label_escape(unescaped);
diff --git a/src/fuzz/fuzz-calendarspec.c b/src/fuzz/fuzz-calendarspec.c
index 573a48a48b..b31a3f2b17 100644
--- a/src/fuzz/fuzz-calendarspec.c
+++ b/src/fuzz/fuzz-calendarspec.c
@@ -12,8 +12,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_free_ char *str = NULL;
int r;
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
assert_se(str = memdup_suffix0(data, size));
diff --git a/src/fuzz/fuzz-catalog.c b/src/fuzz/fuzz-catalog.c
index f3029f49d0..f9561f24c4 100644
--- a/src/fuzz/fuzz-catalog.c
+++ b/src/fuzz/fuzz-catalog.c
@@ -11,8 +11,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_close_ int fd = -EBADF;
_cleanup_ordered_hashmap_free_free_free_ OrderedHashmap *h = NULL;
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
assert_se(h = ordered_hashmap_new(&catalog_hash_ops));
diff --git a/src/fuzz/fuzz-compress.c b/src/fuzz/fuzz-compress.c
index 9cd571dfb8..c3f68f62dd 100644
--- a/src/fuzz/fuzz-compress.c
+++ b/src/fuzz/fuzz-compress.c
@@ -29,10 +29,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
int alg = h->alg;
- /* We don't want to fill the logs with messages about parse errors.
- * Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
log_info("Using compression %s, data size=%zu",
compression_to_string(alg),
diff --git a/src/fuzz/fuzz-env-file.c b/src/fuzz/fuzz-env-file.c
index 6217361b2e..ff7e529ac3 100644
--- a/src/fuzz/fuzz-env-file.c
+++ b/src/fuzz/fuzz-env-file.c
@@ -18,10 +18,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
f = data_to_file(data, size);
assert_se(f);
- /* We don't want to fill the logs with messages about parse errors.
- * Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
(void) load_env_file(f, NULL, &rl);
assert_se(fseek(f, 0, SEEK_SET) == 0);
diff --git a/src/fuzz/fuzz-hostname-setup.c b/src/fuzz/fuzz-hostname-setup.c
index d7c23eef12..4895631b67 100644
--- a/src/fuzz/fuzz-hostname-setup.c
+++ b/src/fuzz/fuzz-hostname-setup.c
@@ -12,10 +12,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
f = data_to_file(data, size);
assert_se(f);
- /* We don't want to fill the logs with messages about parse errors.
- * Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
(void) read_etc_hostname_stream(f, &ret);
diff --git a/src/fuzz/fuzz-json.c b/src/fuzz/fuzz-json.c
index c83ec83328..3d6d689f28 100644
--- a/src/fuzz/fuzz-json.c
+++ b/src/fuzz/fuzz-json.c
@@ -14,9 +14,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
FILE *g = NULL;
int r;
- /* Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
f = data_to_file(data, size);
assert_se(f);
diff --git a/src/fuzz/fuzz-time-util.c b/src/fuzz/fuzz-time-util.c
index 8e6cb8553b..5be2e4f1dd 100644
--- a/src/fuzz/fuzz-time-util.c
+++ b/src/fuzz/fuzz-time-util.c
@@ -9,8 +9,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_free_ char *str = NULL;
usec_t usec;
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
assert_se(str = memdup_suffix0(data, size));
diff --git a/src/fuzz/fuzz-udev-database.c b/src/fuzz/fuzz-udev-database.c
index 2a48c14961..6b4fc8270d 100644
--- a/src/fuzz/fuzz-udev-database.c
+++ b/src/fuzz/fuzz-udev-database.c
@@ -12,8 +12,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_(unlink_tempfilep) char filename[] = "/tmp/fuzz-udev-database.XXXXXX";
_cleanup_fclose_ FILE *f = NULL;
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
assert_se(fmkostemp_safe(filename, "r+", &f) == 0);
if (size != 0)
diff --git a/src/fuzz/fuzz-varlink-idl.c b/src/fuzz/fuzz-varlink-idl.c
index cefc49219c..7ad0f28413 100644
--- a/src/fuzz/fuzz-varlink-idl.c
+++ b/src/fuzz/fuzz-varlink-idl.c
@@ -14,9 +14,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_free_ char *str = NULL, *dump = NULL;
int r;
- log_set_max_level(LOG_CRIT);
- log_parse_environment();
- (void) log_open();
+ fuzz_setup_logging();
assert_se(str = memdup_suffix0(data, size));
diff --git a/src/fuzz/fuzz-varlink.c b/src/fuzz/fuzz-varlink.c
index cbfde088d9..3407760fbf 100644
--- a/src/fuzz/fuzz-varlink.c
+++ b/src/fuzz/fuzz-varlink.c
@@ -92,8 +92,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_(varlink_flush_close_unrefp) Varlink *c = NULL;
_cleanup_(sd_event_unrefp) sd_event *e = NULL;
- log_set_max_level(LOG_CRIT);
- log_parse_environment();
+ fuzz_setup_logging();
assert_se(null = fopen("/dev/null", "we"));
diff --git a/src/fuzz/fuzz.h b/src/fuzz/fuzz.h
index 77e0ad98dc..698ba42d2f 100644
--- a/src/fuzz/fuzz.h
+++ b/src/fuzz/fuzz.h
@@ -28,5 +28,13 @@ static inline bool outside_size_range(size_t size, size_t lower, size_t upper) {
return false;
}
+static inline void fuzz_setup_logging(void) {
+ /* We don't want to fill the logs and slow down stuff when running
+ * in a fuzzing mode, so disable most of the logging. */
+ log_set_max_level(LOG_CRIT);
+ log_parse_environment();
+ log_open();
+}
+
/* Force value to not be optimized away. */
#define DO_NOT_OPTIMIZE(value) ({ asm volatile("" : : "g"(value) : "memory"); })
diff --git a/src/journal-remote/fuzz-journal-remote.c b/src/journal-remote/fuzz-journal-remote.c
index ab4e731000..557100bb96 100644
--- a/src/journal-remote/fuzz-journal-remote.c
+++ b/src/journal-remote/fuzz-journal-remote.c
@@ -30,8 +30,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (outside_size_range(size, 3, 65536))
return 0;
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_ERR);
+ fuzz_setup_logging();
assert_se(mkdtemp_malloc("/tmp/fuzz-journal-remote-XXXXXX", &tmp) >= 0);
assert_se(name = path_join(tmp, "fuzz-journal-remote.XXXXXX.journal"));
diff --git a/src/journal/fuzz-journald-audit.c b/src/journal/fuzz-journald-audit.c
index 6e8e18048e..9bf7d01e57 100644
--- a/src/journal/fuzz-journald-audit.c
+++ b/src/journal/fuzz-journald-audit.c
@@ -7,6 +7,8 @@
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
Server s;
+ fuzz_setup_logging();
+
dummy_server_init(&s, data, size);
process_audit_string(&s, 0, s.buffer, size);
server_done(&s);
diff --git a/src/journal/fuzz-journald-kmsg.c b/src/journal/fuzz-journald-kmsg.c
index ec22f14ccb..104a9b3a7d 100644
--- a/src/journal/fuzz-journald-kmsg.c
+++ b/src/journal/fuzz-journald-kmsg.c
@@ -10,10 +10,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size == 0)
return 0;
- /* We don't want to fill the logs with assert warnings.
- * Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
dummy_server_init(&s, data, size);
dev_kmsg_record(&s, s.buffer, size);
diff --git a/src/journal/fuzz-journald-native-fd.c b/src/journal/fuzz-journald-native-fd.c
index edbf834478..110eb7f5bf 100644
--- a/src/journal/fuzz-journald-native-fd.c
+++ b/src/journal/fuzz-journald-native-fd.c
@@ -18,8 +18,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
struct ucred ucred;
struct timeval *tv = NULL;
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
dummy_server_init(&s, NULL, 0);
diff --git a/src/journal/fuzz-journald-native.c b/src/journal/fuzz-journald-native.c
index 6531c4f668..6738d26e97 100644
--- a/src/journal/fuzz-journald-native.c
+++ b/src/journal/fuzz-journald-native.c
@@ -5,6 +5,8 @@
#include "journald-native.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ fuzz_setup_logging();
+
fuzz_journald_processing_function(data, size, server_process_native_message);
return 0;
}
diff --git a/src/journal/fuzz-journald-stream.c b/src/journal/fuzz-journald-stream.c
index ed52f950d2..d4032cdc51 100644
--- a/src/journal/fuzz-journald-stream.c
+++ b/src/journal/fuzz-journald-stream.c
@@ -19,8 +19,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (outside_size_range(size, 1, 65536))
return 0;
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
assert_se(socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0, stream_fds) >= 0);
dummy_server_init(&s, NULL, 0);
diff --git a/src/journal/fuzz-journald-syslog.c b/src/journal/fuzz-journald-syslog.c
index 72ec610fbf..b3e2d3c09c 100644
--- a/src/journal/fuzz-journald-syslog.c
+++ b/src/journal/fuzz-journald-syslog.c
@@ -5,6 +5,8 @@
#include "journald-syslog.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ fuzz_setup_logging();
+
fuzz_journald_processing_function(data, size, server_process_syslog_message);
return 0;
}
diff --git a/src/libsystemd-network/fuzz-dhcp-client.c b/src/libsystemd-network/fuzz-dhcp-client.c
index bdd8a483a1..91e2ff7a51 100644
--- a/src/libsystemd-network/fuzz-dhcp-client.c
+++ b/src/libsystemd-network/fuzz-dhcp-client.c
@@ -56,8 +56,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
assert_se(setenv("SYSTEMD_NETWORK_TEST_MODE", "1", 1) >= 0);
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
r = sd_dhcp_client_new(&client, false);
assert_se(r >= 0);
diff --git a/src/libsystemd-network/fuzz-dhcp-server-relay.c b/src/libsystemd-network/fuzz-dhcp-server-relay.c
index a53e1c2537..3241d7c8da 100644
--- a/src/libsystemd-network/fuzz-dhcp-server-relay.c
+++ b/src/libsystemd-network/fuzz-dhcp-server-relay.c
@@ -25,6 +25,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size < sizeof(DHCPMessage))
return 0;
+ fuzz_setup_logging();
+
assert_se(sd_dhcp_server_new(&server, 1) >= 0);
assert_se(sd_dhcp_server_attach_event(server, NULL, 0) >= 0);
assert_se(sd_dhcp_server_configure_pool(server, &address, 24, 0, 0) >= 0);
diff --git a/src/libsystemd-network/fuzz-dhcp-server.c b/src/libsystemd-network/fuzz-dhcp-server.c
index 192e209a2f..a294324cde 100644
--- a/src/libsystemd-network/fuzz-dhcp-server.c
+++ b/src/libsystemd-network/fuzz-dhcp-server.c
@@ -78,6 +78,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size < sizeof(DHCPMessage))
return 0;
+ fuzz_setup_logging();
+
assert_se(duped = memdup(data, size));
assert_se(sd_dhcp_server_new(&server, 1) >= 0);
diff --git a/src/libsystemd-network/fuzz-dhcp6-client.c b/src/libsystemd-network/fuzz-dhcp6-client.c
index 204c0e15d2..b879e1b469 100644
--- a/src/libsystemd-network/fuzz-dhcp6-client.c
+++ b/src/libsystemd-network/fuzz-dhcp6-client.c
@@ -75,8 +75,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
assert_se(setenv("SYSTEMD_NETWORK_TEST_MODE", "1", 1) >= 0);
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
if (outside_size_range(size, 0, 65536))
return 0;
diff --git a/src/libsystemd-network/fuzz-lldp-rx.c b/src/libsystemd-network/fuzz-lldp-rx.c
index 2d8e201854..64f96ae2cb 100644
--- a/src/libsystemd-network/fuzz-lldp-rx.c
+++ b/src/libsystemd-network/fuzz-lldp-rx.c
@@ -26,6 +26,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (outside_size_range(size, 0, 2048))
return 0;
+ fuzz_setup_logging();
+
assert_se(sd_event_new(&e) == 0);
assert_se(sd_lldp_rx_new(&lldp_rx) >= 0);
assert_se(sd_lldp_rx_set_ifindex(lldp_rx, 42) >= 0);
diff --git a/src/libsystemd-network/fuzz-ndisc-rs.c b/src/libsystemd-network/fuzz-ndisc-rs.c
index 54dbfc1c76..a89e2b0ed7 100644
--- a/src/libsystemd-network/fuzz-ndisc-rs.c
+++ b/src/libsystemd-network/fuzz-ndisc-rs.c
@@ -23,6 +23,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (outside_size_range(size, 0, 2048))
return 0;
+ fuzz_setup_logging();
+
assert_se(sd_event_new(&e) >= 0);
assert_se(sd_ndisc_new(&nd) >= 0);
assert_se(sd_ndisc_attach_event(nd, e, 0) >= 0);
diff --git a/src/libsystemd/sd-bus/fuzz-bus-match.c b/src/libsystemd/sd-bus/fuzz-bus-match.c
index f7f12746e5..16da534245 100644
--- a/src/libsystemd/sd-bus/fuzz-bus-match.c
+++ b/src/libsystemd/sd-bus/fuzz-bus-match.c
@@ -18,10 +18,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (outside_size_range(size, 0, 65536))
return 0;
- /* We don't want to fill the logs with messages about parse errors.
- * Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
r = sd_bus_new(&bus);
assert_se(r >= 0);
diff --git a/src/libsystemd/sd-bus/fuzz-bus-message.c b/src/libsystemd/sd-bus/fuzz-bus-message.c
index 9b04b4422b..ca7091eff2 100644
--- a/src/libsystemd/sd-bus/fuzz-bus-message.c
+++ b/src/libsystemd/sd-bus/fuzz-bus-message.c
@@ -17,10 +17,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
FILE *g = NULL;
int r;
- /* We don't want to fill the logs with messages about parse errors.
- * Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
r = sd_bus_new(&bus);
assert_se(r >= 0);
diff --git a/src/network/fuzz-netdev-parser.c b/src/network/fuzz-netdev-parser.c
index 77e87e9c43..f0988bd4cc 100644
--- a/src/network/fuzz-netdev-parser.c
+++ b/src/network/fuzz-netdev-parser.c
@@ -14,8 +14,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (outside_size_range(size, 0, 65536))
return 0;
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
assert_se(fmkostemp_safe(netdev_config, "r+", &f) == 0);
if (size != 0)
diff --git a/src/network/fuzz-network-parser.c b/src/network/fuzz-network-parser.c
index 0c9d6d2110..eb17f09ca0 100644
--- a/src/network/fuzz-network-parser.c
+++ b/src/network/fuzz-network-parser.c
@@ -14,8 +14,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (outside_size_range(size, 0, 65536))
return 0;
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
assert_se(fmkostemp_safe(network_config, "r+", &f) == 0);
if (size != 0)
diff --git a/src/nspawn/fuzz-nspawn-oci.c b/src/nspawn/fuzz-nspawn-oci.c
index 5d0383479b..daa478e83c 100644
--- a/src/nspawn/fuzz-nspawn-oci.c
+++ b/src/nspawn/fuzz-nspawn-oci.c
@@ -15,10 +15,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
f = data_to_file(data, size);
assert_se(f);
- /* We don't want to fill the logs with messages about parse errors.
- * Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
(void) oci_load(f, "/dev/null", &s);
diff --git a/src/nspawn/fuzz-nspawn-settings.c b/src/nspawn/fuzz-nspawn-settings.c
index 40ee78438d..e45bfd8fdd 100644
--- a/src/nspawn/fuzz-nspawn-settings.c
+++ b/src/nspawn/fuzz-nspawn-settings.c
@@ -15,10 +15,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
f = data_to_file(data, size);
assert_se(f);
- /* We don't want to fill the logs with messages about parse errors.
- * Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
(void) settings_load(f, "/dev/null", &s);
diff --git a/src/resolve/fuzz-dns-packet.c b/src/resolve/fuzz-dns-packet.c
index de5ee20434..a5b1fd64f7 100644
--- a/src/resolve/fuzz-dns-packet.c
+++ b/src/resolve/fuzz-dns-packet.c
@@ -10,6 +10,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (outside_size_range(size, 0, DNS_PACKET_SIZE_MAX))
return 0;
+ fuzz_setup_logging();
+
assert_se(dns_packet_new(&p, DNS_PROTOCOL_DNS, 0, DNS_PACKET_SIZE_MAX) >= 0);
p->size = 0; /* by default append starts after the header, undo that */
assert_se(dns_packet_append_blob(p, data, size, NULL) >= 0);
diff --git a/src/resolve/fuzz-etc-hosts.c b/src/resolve/fuzz-etc-hosts.c
index bd6d0a8d5d..9fb1ee1b0b 100644
--- a/src/resolve/fuzz-etc-hosts.c
+++ b/src/resolve/fuzz-etc-hosts.c
@@ -8,8 +8,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_(etc_hosts_clear) EtcHosts h = {};
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
f = data_to_file(data, size);
assert_se(f);
diff --git a/src/resolve/fuzz-resource-record.c b/src/resolve/fuzz-resource-record.c
index 3472721356..358a5c7594 100644
--- a/src/resolve/fuzz-resource-record.c
+++ b/src/resolve/fuzz-resource-record.c
@@ -18,6 +18,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (dns_resource_record_new_from_raw(&rr, data, size) < 0)
return 0;
+ fuzz_setup_logging();
+
assert_se(copy = dns_resource_record_copy(rr));
assert_se(dns_resource_record_equal(copy, rr) > 0);
diff --git a/src/systemctl/fuzz-systemctl-parse-argv.c b/src/systemctl/fuzz-systemctl-parse-argv.c
index a97db68d2d..9ea8f7ae87 100644
--- a/src/systemctl/fuzz-systemctl-parse-argv.c
+++ b/src/systemctl/fuzz-systemctl-parse-argv.c
@@ -22,10 +22,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 16*1024)
return 0; /* See the comment below about the limit for strv_length(). */
- /* We don't want to fill the logs with messages about parse errors.
- * Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
arg_pager_flags = PAGER_DISABLE; /* We shouldn't execute the pager */
diff --git a/src/udev/fido_id/fuzz-fido-id-desc.c b/src/udev/fido_id/fuzz-fido-id-desc.c
index dd2ae5b3ac..040d77a487 100644
--- a/src/udev/fido_id/fuzz-fido-id-desc.c
+++ b/src/udev/fido_id/fuzz-fido-id-desc.c
@@ -10,10 +10,7 @@
#include "log.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- /* We don't want to fill the logs with messages about parse errors.
- * Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
if (outside_size_range(size, 0, HID_MAX_DESCRIPTOR_SIZE))
return 0;
diff --git a/src/udev/fuzz-udev-rules.c b/src/udev/fuzz-udev-rules.c
index aff176eb1b..0a1056d4b5 100644
--- a/src/udev/fuzz-udev-rules.c
+++ b/src/udev/fuzz-udev-rules.c
@@ -18,8 +18,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (outside_size_range(size, 0, 65536))
return 0;
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
assert_se(fmkostemp_safe(filename, "r+", &f) == 0);
if (size != 0)
diff --git a/src/udev/net/fuzz-link-parser.c b/src/udev/net/fuzz-link-parser.c
index c809791bc1..2833162cc1 100644
--- a/src/udev/net/fuzz-link-parser.c
+++ b/src/udev/net/fuzz-link-parser.c
@@ -14,8 +14,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (outside_size_range(size, 0, 65536))
return 0;
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
assert_se(fmkostemp_safe(filename, "r+", &f) == 0);
if (size != 0)
diff --git a/src/xdg-autostart-generator/fuzz-xdg-desktop.c b/src/xdg-autostart-generator/fuzz-xdg-desktop.c
index b1b035d94e..9aca797e1b 100644
--- a/src/xdg-autostart-generator/fuzz-xdg-desktop.c
+++ b/src/xdg-autostart-generator/fuzz-xdg-desktop.c
@@ -20,10 +20,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (outside_size_range(size, 0, 65536))
return 0;
- /* We don't want to fill the logs with messages about parse errors.
- * Disable most logging if not running standalone */
- if (!getenv("SYSTEMD_LOG_LEVEL"))
- log_set_max_level(LOG_CRIT);
+ fuzz_setup_logging();
assert_se(mkdtemp_malloc("/tmp/fuzz-xdg-desktop-XXXXXX", &tmpdir) >= 0);