1 Star 0 Fork 49

YYNA/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0140-tests-add-a-rudimentary-fuzzer-for-server_process_sy.patch 2.05 KB
一键复制 编辑 原始数据 按行查看 历史
张彬琛 提交于 2021-01-20 13:59 . import systemd-239-29.el8.src.rpm
From 86cf4118a04afbc67d0231f8b53cf3629258032a Mon Sep 17 00:00:00 2001
From: Evgeny Vereshchagin <evvers@ya.ru>
Date: Mon, 3 Sep 2018 06:18:26 +0300
Subject: [PATCH] tests: add a rudimentary fuzzer for
server_process_syslog_message (#9979)
(cherry picked from commit a70f343cacf03ac51cdefb0d2e7651b04fd2e23a)
Resolves: #1696224
---
src/fuzz/fuzz-journald-syslog.c | 29 +++++++++++++++++++++++++++++
src/fuzz/meson.build | 5 +++++
2 files changed, 34 insertions(+)
create mode 100644 src/fuzz/fuzz-journald-syslog.c
diff --git a/src/fuzz/fuzz-journald-syslog.c b/src/fuzz/fuzz-journald-syslog.c
new file mode 100644
index 0000000000..7730f60875
--- /dev/null
+++ b/src/fuzz/fuzz-journald-syslog.c
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
+#include "alloc-util.h"
+#include "fuzz.h"
+#include "journald-server.h"
+#include "journald-syslog.h"
+#include "sd-event.h"
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ Server s = {};
+ char *label = NULL;
+ size_t label_len = 0;
+ struct ucred *ucred = NULL;
+ struct timeval *tv = NULL;
+
+ if (size == 0)
+ return 0;
+
+ assert_se(sd_event_default(&s.event) >= 0);
+ s.syslog_fd = s.native_fd = s.stdout_fd = s.dev_kmsg_fd = s.audit_fd = s.hostname_fd = s.notify_fd = -1;
+ s.buffer = memdup_suffix0(data, size);
+ assert_se(s.buffer);
+ s.buffer_size = size + 1;
+ s.storage = STORAGE_NONE;
+ server_process_syslog_message(&s, s.buffer, size, ucred, tv, label, label_len);
+ server_done(&s);
+
+ return 0;
+}
diff --git a/src/fuzz/meson.build b/src/fuzz/meson.build
index ad44778889..28770b68b8 100644
--- a/src/fuzz/meson.build
+++ b/src/fuzz/meson.build
@@ -19,6 +19,11 @@ fuzzers += [
libshared],
[libmount]],
+ [['src/fuzz/fuzz-journald-syslog.c'],
+ [libjournal_core,
+ libshared],
+ [libselinux]],
+
[['src/fuzz/fuzz-journal-remote.c'],
[libsystemd_journal_remote,
libshared],
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ful9/systemd.git
git@gitee.com:ful9/systemd.git
ful9
systemd
systemd
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385