From 7d52a608438948b523681653550bc2e90ee9dc9b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 5 Jun 2025 22:21:16 +0200 Subject: [PATCH] journal: use EBADMSG for invalid data in file mmap We must assume that any data in the mmap can change anytime because the file is deallocated or similar. Let's strictly use EBADMSG for reporting invalid file contents though (as opposed to using EINVAL if our own code passes a wrong parameter somwhere). --- src/libsystemd/sd-journal/journal-file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 229a19d8e7..786d757e9c 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -1404,7 +1404,7 @@ static int journal_file_link_field( assert(offset > 0); if (o->object.type != OBJECT_FIELD) - return -EINVAL; + return -EBADMSG; m = le64toh(READ_NOW(f->header->field_hash_table_size)) / sizeof(HashItem); if (m <= 0) @@ -1449,7 +1449,7 @@ static int journal_file_link_data( assert(offset > 0); if (o->object.type != OBJECT_DATA) - return -EINVAL; + return -EBADMSG; m = le64toh(READ_NOW(f->header->data_hash_table_size)) / sizeof(HashItem); if (m <= 0) @@ -2233,7 +2233,7 @@ static int journal_file_link_entry( assert(offset > 0); if (o->object.type != OBJECT_ENTRY) - return -EINVAL; + return -EBADMSG; __atomic_thread_fence(__ATOMIC_SEQ_CST);