加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-sd-journal-fix-segfault-when-match_new-fails.patch 1.93 KB
一键复制 编辑 原始数据 按行查看 历史
From 4bf497c3814e2f612cb055b838a656e6e14c0ed0 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Thu, 23 Dec 2021 21:45:29 +0900
Subject: [PATCH] sd-journal: fix segfault when match_new() fails
Fixes #21867.
(cherry picked from commit 39dfc0de05238410e2cd4d7c0176a3f3994cc563)
Conflict:NA
Reference:https://github.com/systemd/systemd/commit/4bf497c3814e2f612cb055b838a656e6e14c0ed0
---
src/libsystemd/sd-journal/sd-journal.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c
index 63b8f0dc7b..dd28b8008f 100644
--- a/src/libsystemd/sd-journal/sd-journal.c
+++ b/src/libsystemd/sd-journal/sd-journal.c
@@ -211,7 +211,7 @@ static Match *match_new(Match *p, MatchType t) {
return m;
}
-static void match_free(Match *m) {
+static Match *match_free(Match *m) {
assert(m);
while (m->matches)
@@ -221,14 +221,14 @@ static void match_free(Match *m) {
LIST_REMOVE(matches, m->parent->matches, m);
free(m->data);
- free(m);
+ return mfree(m);
}
-static void match_free_if_empty(Match *m) {
+static Match *match_free_if_empty(Match *m) {
if (!m || m->matches)
- return;
+ return m;
- match_free(m);
+ return match_free(m);
}
_public_ int sd_journal_add_match(sd_journal *j, const void *data, size_t size) {
@@ -323,9 +323,9 @@ _public_ int sd_journal_add_match(sd_journal *j, const void *data, size_t size)
fail:
match_free(m);
match_free_if_empty(add_here);
- match_free_if_empty(j->level2);
- match_free_if_empty(j->level1);
- match_free_if_empty(j->level0);
+ j->level2 = match_free_if_empty(j->level2);
+ j->level1 = match_free_if_empty(j->level1);
+ j->level0 = match_free_if_empty(j->level0);
return -ENOMEM;
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化