1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

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.
This commit is contained in:
Yu Watanabe 2023-05-01 12:54:15 +09:00
parent 3092eaa72e
commit b72fd2af86

View File

@ -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),