summaryrefslogtreecommitdiffstats
path: root/src/fuzz/fuzz-varlink-idl.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
commit55944e5e40b1be2afc4855d8d2baf4b73d1876b5 (patch)
tree33f869f55a1b149e9b7c2b7e201867ca5dd52992 /src/fuzz/fuzz-varlink-idl.c
parentInitial commit. (diff)
downloadsystemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.tar.xz
systemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.zip
Adding upstream version 255.4.upstream/255.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/fuzz/fuzz-varlink-idl.c')
-rw-r--r--src/fuzz/fuzz-varlink-idl.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/fuzz/fuzz-varlink-idl.c b/src/fuzz/fuzz-varlink-idl.c
new file mode 100644
index 0000000..2436342
--- /dev/null
+++ b/src/fuzz/fuzz-varlink-idl.c
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include <unistd.h>
+
+#include "errno-util.h"
+#include "fd-util.h"
+#include "fuzz.h"
+#include "io-util.h"
+#include "varlink-idl.h"
+#include "log.h"
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ _cleanup_(varlink_interface_freep) VarlinkInterface *vi = NULL;
+ _cleanup_free_ char *str = NULL, *dump = NULL;
+ int r;
+
+ if (outside_size_range(size, 0, 64 * 1024))
+ return 0;
+
+ fuzz_setup_logging();
+
+ assert_se(str = memdup_suffix0(data, size));
+
+ r = varlink_idl_parse(str, /* line= */ NULL, /* column= */ NULL, &vi);
+ if (r < 0) {
+ log_debug_errno(r, "Failed to parse varlink interface definition: %m");
+ return 0;
+ }
+
+ assert_se(varlink_idl_format(vi, &dump) >= 0);
+ (void) varlink_idl_consistent(vi, LOG_DEBUG);
+
+ return 0;
+}