Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
systemd-solve-that-rsyslog-reads-journal-s-object-of.patch 2.12 KB
Copy Edit Raw Blame History
胡宇彪 authored 2023-07-31 10:00 . sync the patch from v249
From 6aa35d7d911b6895043f222293703ef7cf60aca1 Mon Sep 17 00:00:00 2001
From: yefei25 <yefei25@huawei.com>
Date: Thu, 5 Mar 2020 21:45:36 +0800
Subject: [PATCH] systemd: solve that rsyslog reads journal's object of
size 0
Signed-off-by: yefei25 <yefei25@huawei.com>
---
src/libsystemd/sd-journal/journal-file.c | 5 +++--
src/libsystemd/sd-journal/sd-journal.c | 7 ++++++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c
index 2ead295..9962d3b 100644
--- a/src/libsystemd/sd-journal/journal-file.c
+++ b/src/libsystemd/sd-journal/journal-file.c
@@ -898,8 +898,9 @@ static int check_object(JournalFile *f, Object *o, uint64_t offset) {
le64toh(o->tag.epoch), offset);
break;
+ default:
+ return -EBADMSG;
}
-
return 0;
}
@@ -1804,7 +1805,7 @@ int journal_file_data_payload(
}
size = le64toh(READ_NOW(o->object.size));
- if (size < journal_file_data_payload_offset(f))
+ if (size == 0 || o->object.type == 0 || size < journal_file_data_payload_offset(f))
return -EBADMSG;
size -= journal_file_data_payload_offset(f);
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c
index 898218e..f6090dd 100644
--- a/src/libsystemd/sd-journal/sd-journal.c
+++ b/src/libsystemd/sd-journal/sd-journal.c
@@ -114,6 +114,10 @@ static void init_location(Location *l, LocationType type, JournalFile *f, Object
assert(IN_SET(type, LOCATION_DISCRETE, LOCATION_SEEK));
assert(f);
+ if(o->object.type != OBJECT_ENTRY || o->object.size == 0){
+ return;
+ }
+
*l = (Location) {
.type = type,
.seqnum = le64toh(o->entry.seqnum),
@@ -851,7 +855,8 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
return r;
set_location(j, new_file, o);
-
+ if(o->object.size == 0)
+ return -EBADMSG;
return 1;
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化