daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
ff6046
From f9a28e4e070ed86a0c5138dbfb98a60f00beb8d4 Mon Sep 17 00:00:00 2001
ff6046
From: Evgeny Vereshchagin <evvers@ya.ru>
ff6046
Date: Mon, 3 Sep 2018 07:05:48 +0000
ff6046
Subject: [PATCH] tests: add a fuzzer for server_process_native_message
ff6046
ff6046
(cherry picked from commit 9cdea02db57a36442ad9e9afcd67760ca319173a)
ff6046
ff6046
Resolves: #1696224
ff6046
---
ff6046
 src/fuzz/fuzz-journald-native.c | 10 ++++++++++
ff6046
 src/fuzz/meson.build            |  5 +++++
ff6046
 2 files changed, 15 insertions(+)
ff6046
 create mode 100644 src/fuzz/fuzz-journald-native.c
ff6046
ff6046
diff --git a/src/fuzz/fuzz-journald-native.c b/src/fuzz/fuzz-journald-native.c
ff6046
new file mode 100644
ff6046
index 0000000000..f4de5fd8eb
ff6046
--- /dev/null
ff6046
+++ b/src/fuzz/fuzz-journald-native.c
ff6046
@@ -0,0 +1,10 @@
ff6046
+/* SPDX-License-Identifier: LGPL-2.1+ */
ff6046
+
ff6046
+#include "fuzz.h"
ff6046
+#include "fuzz-journald.h"
ff6046
+#include "journald-native.h"
ff6046
+
ff6046
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
ff6046
+        fuzz_journald_processing_function(data, size, server_process_native_message);
ff6046
+        return 0;
ff6046
+}
ff6046
diff --git a/src/fuzz/meson.build b/src/fuzz/meson.build
ff6046
index 28770b68b8..5a97ef5091 100644
ff6046
--- a/src/fuzz/meson.build
ff6046
+++ b/src/fuzz/meson.build
ff6046
@@ -19,6 +19,11 @@ fuzzers += [
ff6046
           libshared],
ff6046
          [libmount]],
ff6046
 
ff6046
+        [['src/fuzz/fuzz-journald-native.c'],
ff6046
+         [libjournal_core,
ff6046
+          libshared],
ff6046
+         [libselinux]],
ff6046
+
ff6046
         [['src/fuzz/fuzz-journald-syslog.c'],
ff6046
          [libjournal_core,
ff6046
           libshared],