summaryrefslogtreecommitdiffstats
path: root/src/fuzz
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-12-31 21:02:17 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-01-18 23:04:19 +0100
commite2e78881919ad6f4cb5b8f316564534b213644c4 (patch)
tree26348d0037d2ed5524b3b92c869c547e8be4c901 /src/fuzz
parentmeson.build: drop unused variable (diff)
downloadsystemd-e2e78881919ad6f4cb5b8f316564534b213644c4.tar.xz
systemd-e2e78881919ad6f4cb5b8f316564534b213644c4.zip
xdg: move tests for xdg-autostart-generator
Then, we can drop src/xdg-autostart-generator from include directories later.
Diffstat (limited to 'src/fuzz')
-rw-r--r--src/fuzz/fuzz-xdg-desktop.c36
-rw-r--r--src/fuzz/meson.build2
2 files changed, 1 insertions, 37 deletions
diff --git a/src/fuzz/fuzz-xdg-desktop.c b/src/fuzz/fuzz-xdg-desktop.c
deleted file mode 100644
index 23077e48dc..0000000000
--- a/src/fuzz/fuzz-xdg-desktop.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-
-#include "alloc-util.h"
-#include "fd-util.h"
-#include "fs-util.h"
-#include "rm-rf.h"
-#include "string-util.h"
-#include "strv.h"
-#include "tests.h"
-#include "tmpfile-util.h"
-#include "fuzz.h"
-#include "xdg-autostart-service.h"
-
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- _cleanup_(unlink_tempfilep) char name[] = "/tmp/fuzz-xdg-desktop.XXXXXX";
- _cleanup_close_ int fd = -1;
- _cleanup_(xdg_autostart_service_freep) XdgAutostartService *service = NULL;
- _cleanup_(rm_rf_physical_and_freep) char *tmpdir = 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);
-
- assert_se(mkdtemp_malloc("/tmp/fuzz-xdg-desktop-XXXXXX", &tmpdir) >= 0);
-
- fd = mkostemp_safe(name);
- assert_se(fd >= 0);
- assert_se(write(fd, data, size) == (ssize_t) size);
-
- assert_se(service = xdg_autostart_service_parse_desktop(name));
- assert_se(service->name = strdup("fuzz-xdg-desktop.service"));
- (void) xdg_autostart_service_generate_unit(service, tmpdir);
-
- return 0;
-}
diff --git a/src/fuzz/meson.build b/src/fuzz/meson.build
index 83527a68fb..de6fe482e7 100644
--- a/src/fuzz/meson.build
+++ b/src/fuzz/meson.build
@@ -145,7 +145,7 @@ fuzzers += [
[libshared],
[]],
- [['src/fuzz/fuzz-xdg-desktop.c',
+ [['src/xdg-autostart-generator/fuzz-xdg-desktop.c',
'src/xdg-autostart-generator/xdg-autostart-service.h',
'src/xdg-autostart-generator/xdg-autostart-service.c'],
[],