chiark / gitweb /
journal: Add missing byte order conversions
authorGeorge McCollister <george.mccollister@gmail.com>
Tue, 31 Dec 2013 20:37:32 +0000 (14:37 -0600)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 5 Jan 2014 14:36:32 +0000 (09:36 -0500)
Convert entry_array.items[0] to host byte order prior to passing it to
chain_cache_put().

[zj: also use le64toh in journal-verify.c]

https://bugs.freedesktop.org/show_bug.cgi?id=73194

src/journal/journal-file.c
src/journal/journal-verify.c

index 121b40a58324a46064f605d718de78b2cfb30091..275324b672e554be629af524f3175de73d2671b6 100644 (file)
@@ -1452,7 +1452,7 @@ static int generic_array_get(
 
 found:
         /* Let's cache this item for the next invocation */
 
 found:
         /* Let's cache this item for the next invocation */
-        chain_cache_put(f->chain_cache, ci, first, a, o->entry_array.items[0], t, i);
+        chain_cache_put(f->chain_cache, ci, first, a, le64toh(o->entry_array.items[0]), t, i);
 
         r = journal_file_move_to_object(f, OBJECT_ENTRY, p, &o);
         if (r < 0)
 
         r = journal_file_move_to_object(f, OBJECT_ENTRY, p, &o);
         if (r < 0)
@@ -1685,7 +1685,7 @@ found:
                 return 0;
 
         /* Let's cache this item for the next invocation */
                 return 0;
 
         /* Let's cache this item for the next invocation */
-        chain_cache_put(f->chain_cache, ci, first, a, array->entry_array.items[0], t, subtract_one ? (i > 0 ? i-1 : (uint64_t) -1) : i);
+        chain_cache_put(f->chain_cache, ci, first, a, le64toh(array->entry_array.items[0]), t, subtract_one ? (i > 0 ? i-1 : (uint64_t) -1) : i);
 
         if (subtract_one && i == 0)
                 p = last_p;
 
         if (subtract_one && i == 0)
                 p = last_p;
index 340581153425cb67c979d18877404b65c95700c3..82b0f0a98bb23a7ffa0bdc657819eabc78f09eb5 100644 (file)
@@ -249,12 +249,12 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
                 }
 
                 for (i = 0; i < journal_file_entry_array_n_items(o); i++)
                 }
 
                 for (i = 0; i < journal_file_entry_array_n_items(o); i++)
-                        if (o->entry_array.items[i] != 0 &&
-                            !VALID64(o->entry_array.items[i])) {
+                        if (le64toh(o->entry_array.items[i]) != 0 &&
+                            !VALID64(le64toh(o->entry_array.items[i]))) {
                                 log_error(OFSfmt": invalid object entry array item (%"PRIu64"/%"PRIu64"): "OFSfmt,
                                           offset,
                                           i, journal_file_entry_array_n_items(o),
                                 log_error(OFSfmt": invalid object entry array item (%"PRIu64"/%"PRIu64"): "OFSfmt,
                                           offset,
                                           i, journal_file_entry_array_n_items(o),
-                                          o->entry_array.items[i]);
+                                          le64toh(o->entry_array.items[i]));
                                 return -EBADMSG;
                         }
 
                                 return -EBADMSG;
                         }