summaryrefslogtreecommitdiff
path: root/src/fuzz
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2019-03-10 20:53:57 +0100
committerFrantisek Sumsal <frantisek@sumsal.cz>2019-03-11 13:00:32 +0100
commite5f274bee1c5652ebdadf7bc2c06a4437a8389f0 (patch)
tree0176a1f8990776583ed6c00ec24af220c0e749c5 /src/fuzz
parent68b7f7ac89b3f143c369526eede40e229869e7dd (diff)
downloadsystemd-e5f274bee1c5652ebdadf7bc2c06a4437a8389f0.tar.gz
fuzz: add bus-label fuzzer
Diffstat (limited to 'src/fuzz')
-rw-r--r--src/fuzz/fuzz-bus-label.c18
-rw-r--r--src/fuzz/meson.build4
2 files changed, 22 insertions, 0 deletions
diff --git a/src/fuzz/fuzz-bus-label.c b/src/fuzz/fuzz-bus-label.c
new file mode 100644
index 0000000000..46a3d23dc4
--- /dev/null
+++ b/src/fuzz/fuzz-bus-label.c
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
+#include <errno.h>
+
+#include "alloc-util.h"
+#include "bus-label.h"
+#include "fuzz.h"
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ _cleanup_free_ char *unescaped = NULL, *escaped = NULL;
+
+ unescaped = bus_label_unescape_n((const char*)data, size);
+ assert_se(unescaped != NULL);
+ escaped = bus_label_escape(unescaped);
+ assert_se(escaped != NULL);
+
+ return 0;
+}
diff --git a/src/fuzz/meson.build b/src/fuzz/meson.build
index 5138a2c416..ba893cff94 100644
--- a/src/fuzz/meson.build
+++ b/src/fuzz/meson.build
@@ -112,4 +112,8 @@ fuzzers += [
[['src/fuzz/fuzz-compress.c'],
[libshared],
[]],
+
+ [['src/fuzz/fuzz-bus-label.c'],
+ [libshared],
+ []],
]