]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: fix byte-order conversion in journal_file_append_data()
authordongshengyuan <545258830@qq.com>
Fri, 12 Jun 2026 05:41:33 +0000 (13:41 +0800)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 13 Jun 2026 07:18:06 +0000 (16:18 +0900)
head_data_offset is declared as le64_t in journal-def.h, so it must be
assigned with htole64(p), not le64toh(p). All other le64_t field
assignments in this file (hash, next_hash_offset) consistently use
htole64().

On little-endian systems this makes no difference, but on big-endian
systems the field->data link would be stored with incorrect byte order,
corrupting journal file traversal.

Assisted-by: claude-opus-4-8 <noreply@anthropic.com>
src/libsystemd/sd-journal/journal-file.c

index a4b270ceb728d2b7adc10b790a1b9766dcd95040..bd8a4348bda9092ae5cf4e5385ad3a8e42c3a042 100644 (file)
@@ -1915,7 +1915,7 @@ static int journal_file_append_data(
 
         /* ... and link it in. */
         o->data.next_field_offset = fo->field.head_data_offset;
-        fo->field.head_data_offset = le64toh(p);
+        fo->field.head_data_offset = htole64(p);
 
         if (ret_object)
                 *ret_object = o;