summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-05-01 12:54:15 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-05-01 14:25:38 +0900
commitb72fd2af867475a43c17cfe3c89963692f753189 (patch)
tree7196e9eb91d6b4a87d65754a726bff41dae609a2 /src/libsystemd
parent3092eaa72e2ebade043c64ff47cd53bda23b499e (diff)
downloadsystemd-b72fd2af867475a43c17cfe3c89963692f753189.tar.gz
sd-journal: check validity of object type more strictly
Otherwise, the object with invalid type may pass check_object_header() when the requested type is OBJECT_UNUSED.
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-journal/journal-file.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c
index 1ef7559537..81bedfd722 100644
--- a/src/libsystemd/sd-journal/journal-file.c
+++ b/src/libsystemd/sd-journal/journal-file.c
@@ -791,10 +791,10 @@ static int check_object_header(JournalFile *f, Object *o, ObjectType type, uint6
"Attempt to move to overly short object with size %"PRIu64": %" PRIu64,
s, offset);
- if (o->object.type <= OBJECT_UNUSED)
+ if (o->object.type <= OBJECT_UNUSED || o->object.type >= _OBJECT_TYPE_MAX)
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
- "Attempt to move to object with invalid type: %" PRIu64,
- offset);
+ "Attempt to move to object with invalid type (%u): %" PRIu64,
+ o->object.type, offset);
if (type > OBJECT_UNUSED && o->object.type != type)
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),