anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0145-tests-add-a-fuzzer-for-server_process_native_message.patch

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