]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: use EBADMSG for invalid data in file mmap
authorLennart Poettering <lennart@poettering.net>
Thu, 5 Jun 2025 20:21:16 +0000 (22:21 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 4 Aug 2025 18:50:36 +0000 (19:50 +0100)
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).

(cherry picked from commit 7d52a608438948b523681653550bc2e90ee9dc9b)

src/libsystemd/sd-journal/journal-file.c

index 7f16183f7c0fa2e08f2fa604e81c7f013a36ff56..c67dbddaf764d35c3bfc352186c1cf5186d348af 100644 (file)
@@ -1403,7 +1403,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)
@@ -1448,7 +1448,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)
@@ -2229,7 +2229,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);