diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-10-18 23:11:13 +0200 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2023-10-19 11:05:20 +0200 |
commit | 4820c9d41748640ce6a29fc76d6463c822a31662 (patch) | |
tree | 073c65a8e74eaede325f46b32b9615886e0425ae /src/udev | |
parent | Merge pull request #29611 from mrc0mmand/execute-serialize-fuzz (diff) | |
download | systemd-4820c9d41748640ce6a29fc76d6463c822a31662.tar.xz systemd-4820c9d41748640ce6a29fc76d6463c822a31662.zip |
fuzz: unify logging setup
Make sure we don't log anything when running in "fuzzing" mode. Also,
when at it, unify the setup logic into a helper, pretty similar to
the test_setup_logging() one.
Addresses:
- https://github.com/systemd/systemd/pull/29558#pullrequestreview-1676060607
- https://github.com/systemd/systemd/pull/29558#discussion_r1358940663
Diffstat (limited to 'src/udev')
-rw-r--r-- | src/udev/fido_id/fuzz-fido-id-desc.c | 5 | ||||
-rw-r--r-- | src/udev/fuzz-udev-rules.c | 3 | ||||
-rw-r--r-- | src/udev/net/fuzz-link-parser.c | 3 |
3 files changed, 3 insertions, 8 deletions
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) |