|
|
a3e2b5 |
From 86cf4118a04afbc67d0231f8b53cf3629258032a Mon Sep 17 00:00:00 2001
|
|
|
a3e2b5 |
From: Evgeny Vereshchagin <evvers@ya.ru>
|
|
|
a3e2b5 |
Date: Mon, 3 Sep 2018 06:18:26 +0300
|
|
|
a3e2b5 |
Subject: [PATCH] tests: add a rudimentary fuzzer for
|
|
|
a3e2b5 |
server_process_syslog_message (#9979)
|
|
|
a3e2b5 |
|
|
|
a3e2b5 |
(cherry picked from commit a70f343cacf03ac51cdefb0d2e7651b04fd2e23a)
|
|
|
a3e2b5 |
|
|
|
a3e2b5 |
Resolves: #1696224
|
|
|
a3e2b5 |
---
|
|
|
a3e2b5 |
src/fuzz/fuzz-journald-syslog.c | 29 +++++++++++++++++++++++++++++
|
|
|
a3e2b5 |
src/fuzz/meson.build | 5 +++++
|
|
|
a3e2b5 |
2 files changed, 34 insertions(+)
|
|
|
a3e2b5 |
create mode 100644 src/fuzz/fuzz-journald-syslog.c
|
|
|
a3e2b5 |
|
|
|
a3e2b5 |
diff --git a/src/fuzz/fuzz-journald-syslog.c b/src/fuzz/fuzz-journald-syslog.c
|
|
|
a3e2b5 |
new file mode 100644
|
|
|
a3e2b5 |
index 0000000000..7730f60875
|
|
|
a3e2b5 |
--- /dev/null
|
|
|
a3e2b5 |
+++ b/src/fuzz/fuzz-journald-syslog.c
|
|
|
a3e2b5 |
@@ -0,0 +1,29 @@
|
|
|
a3e2b5 |
+/* SPDX-License-Identifier: LGPL-2.1+ */
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
+#include "alloc-util.h"
|
|
|
a3e2b5 |
+#include "fuzz.h"
|
|
|
a3e2b5 |
+#include "journald-server.h"
|
|
|
a3e2b5 |
+#include "journald-syslog.h"
|
|
|
a3e2b5 |
+#include "sd-event.h"
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|
|
a3e2b5 |
+ Server s = {};
|
|
|
a3e2b5 |
+ char *label = NULL;
|
|
|
a3e2b5 |
+ size_t label_len = 0;
|
|
|
a3e2b5 |
+ struct ucred *ucred = NULL;
|
|
|
a3e2b5 |
+ struct timeval *tv = NULL;
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
+ if (size == 0)
|
|
|
a3e2b5 |
+ return 0;
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
+ assert_se(sd_event_default(&s.event) >= 0);
|
|
|
a3e2b5 |
+ s.syslog_fd = s.native_fd = s.stdout_fd = s.dev_kmsg_fd = s.audit_fd = s.hostname_fd = s.notify_fd = -1;
|
|
|
a3e2b5 |
+ s.buffer = memdup_suffix0(data, size);
|
|
|
a3e2b5 |
+ assert_se(s.buffer);
|
|
|
a3e2b5 |
+ s.buffer_size = size + 1;
|
|
|
a3e2b5 |
+ s.storage = STORAGE_NONE;
|
|
|
a3e2b5 |
+ server_process_syslog_message(&s, s.buffer, size, ucred, tv, label, label_len);
|
|
|
a3e2b5 |
+ server_done(&s);
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
+ return 0;
|
|
|
a3e2b5 |
+}
|
|
|
a3e2b5 |
diff --git a/src/fuzz/meson.build b/src/fuzz/meson.build
|
|
|
a3e2b5 |
index ad44778889..28770b68b8 100644
|
|
|
a3e2b5 |
--- a/src/fuzz/meson.build
|
|
|
a3e2b5 |
+++ b/src/fuzz/meson.build
|
|
|
a3e2b5 |
@@ -19,6 +19,11 @@ fuzzers += [
|
|
|
a3e2b5 |
libshared],
|
|
|
a3e2b5 |
[libmount]],
|
|
|
a3e2b5 |
|
|
|
a3e2b5 |
+ [['src/fuzz/fuzz-journald-syslog.c'],
|
|
|
a3e2b5 |
+ [libjournal_core,
|
|
|
a3e2b5 |
+ libshared],
|
|
|
a3e2b5 |
+ [libselinux]],
|
|
|
a3e2b5 |
+
|
|
|
a3e2b5 |
[['src/fuzz/fuzz-journal-remote.c'],
|
|
|
a3e2b5 |
[libsystemd_journal_remote,
|
|
|
a3e2b5 |
libshared],
|