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>
/* ... 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;