naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
b9a53a
From 18a45cf91dbdd075fb55d752f959e84d36f3ab3b Mon Sep 17 00:00:00 2001
b9a53a
From: Evgeny Vereshchagin <evvers@ya.ru>
b9a53a
Date: Fri, 7 Sep 2018 06:13:17 +0000
b9a53a
Subject: [PATCH] tests: put fuzz_journald_processing_function in a .c file
b9a53a
b9a53a
(cherry picked from commit 231dca5579cfba6175d19eee5347d693893fb5aa)
b9a53a
b9a53a
Resolves: #1764560
b9a53a
---
b9a53a
 src/fuzz/fuzz-journald.c | 30 ++++++++++++++++++++++++++++++
b9a53a
 src/fuzz/fuzz-journald.h | 24 ++----------------------
b9a53a
 src/fuzz/meson.build     |  6 ++++--
b9a53a
 3 files changed, 36 insertions(+), 24 deletions(-)
b9a53a
 create mode 100644 src/fuzz/fuzz-journald.c
b9a53a
b9a53a
diff --git a/src/fuzz/fuzz-journald.c b/src/fuzz/fuzz-journald.c
b9a53a
new file mode 100644
b9a53a
index 0000000000..f271d7f2fe
b9a53a
--- /dev/null
b9a53a
+++ b/src/fuzz/fuzz-journald.c
b9a53a
@@ -0,0 +1,30 @@
b9a53a
+/* SPDX-License-Identifier: LGPL-2.1+ */
b9a53a
+
b9a53a
+#include "alloc-util.h"
b9a53a
+#include "fuzz-journald.h"
b9a53a
+#include "journald-server.h"
b9a53a
+#include "sd-event.h"
b9a53a
+
b9a53a
+void fuzz_journald_processing_function(
b9a53a
+                const uint8_t *data,
b9a53a
+                size_t size,
b9a53a
+                void (*f)(Server *s, const char *buf, size_t raw_len, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len)
b9a53a
+        ) {
b9a53a
+        Server s = {};
b9a53a
+        char *label = NULL;
b9a53a
+        size_t label_len = 0;
b9a53a
+        struct ucred *ucred = NULL;
b9a53a
+        struct timeval *tv = NULL;
b9a53a
+
b9a53a
+        if (size == 0)
b9a53a
+                return;
b9a53a
+
b9a53a
+        assert_se(sd_event_default(&s.event) >= 0);
b9a53a
+        s.syslog_fd = s.native_fd = s.stdout_fd = s.dev_kmsg_fd = s.audit_fd = s.hostname_fd = s.notify_fd = -1;
b9a53a
+        s.buffer = memdup_suffix0(data, size);
b9a53a
+        assert_se(s.buffer);
b9a53a
+        s.buffer_size = size + 1;
b9a53a
+        s.storage = STORAGE_NONE;
b9a53a
+        (*f)(&s, s.buffer, size, ucred, tv, label, label_len);
b9a53a
+        server_done(&s);
b9a53a
+}
b9a53a
diff --git a/src/fuzz/fuzz-journald.h b/src/fuzz/fuzz-journald.h
b9a53a
index e66ef54c9b..e9d32a74aa 100644
b9a53a
--- a/src/fuzz/fuzz-journald.h
b9a53a
+++ b/src/fuzz/fuzz-journald.h
b9a53a
@@ -1,30 +1,10 @@
b9a53a
 /* SPDX-License-Identifier: LGPL-2.1+ */
b9a53a
 #pragma once
b9a53a
 
b9a53a
-#include "alloc-util.h"
b9a53a
 #include "journald-server.h"
b9a53a
-#include "sd-event.h"
b9a53a
 
b9a53a
-static void fuzz_journald_processing_function(
b9a53a
+void fuzz_journald_processing_function(
b9a53a
                 const uint8_t *data,
b9a53a
                 size_t size,
b9a53a
                 void (*f)(Server *s, const char *buf, size_t raw_len, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len)
b9a53a
-        ) {
b9a53a
-        Server s = {};
b9a53a
-        char *label = NULL;
b9a53a
-        size_t label_len = 0;
b9a53a
-        struct ucred *ucred = NULL;
b9a53a
-        struct timeval *tv = NULL;
b9a53a
-
b9a53a
-        if (size == 0)
b9a53a
-                return;
b9a53a
-
b9a53a
-        assert_se(sd_event_default(&s.event) >= 0);
b9a53a
-        s.syslog_fd = s.native_fd = s.stdout_fd = s.dev_kmsg_fd = s.audit_fd = s.hostname_fd = s.notify_fd = -1;
b9a53a
-        s.buffer = memdup_suffix0(data, size);
b9a53a
-        assert_se(s.buffer);
b9a53a
-        s.buffer_size = size + 1;
b9a53a
-        s.storage = STORAGE_NONE;
b9a53a
-        (*f)(&s, s.buffer, size, ucred, tv, label, label_len);
b9a53a
-        server_done(&s);
b9a53a
-}
b9a53a
+);
b9a53a
diff --git a/src/fuzz/meson.build b/src/fuzz/meson.build
b9a53a
index 483a952421..1f8631bcc0 100644
b9a53a
--- a/src/fuzz/meson.build
b9a53a
+++ b/src/fuzz/meson.build
b9a53a
@@ -33,12 +33,14 @@ fuzzers += [
b9a53a
           libshared],
b9a53a
          [libmount]],
b9a53a
 
b9a53a
-        [['src/fuzz/fuzz-journald-native.c'],
b9a53a
+        [['src/fuzz/fuzz-journald-native.c',
b9a53a
+          'src/fuzz/fuzz-journald.c'],
b9a53a
          [libjournal_core,
b9a53a
           libshared],
b9a53a
          [libselinux]],
b9a53a
 
b9a53a
-        [['src/fuzz/fuzz-journald-syslog.c'],
b9a53a
+        [['src/fuzz/fuzz-journald-syslog.c',
b9a53a
+          'src/fuzz/fuzz-journald.c'],
b9a53a
          [libjournal_core,
b9a53a
           libshared],
b9a53a
          [libselinux]],