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