richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
572a44
From dcf643901f6aeeda806e19fa7cbb766ded3f3d44 Mon Sep 17 00:00:00 2001
572a44
From: George McCollister <george.mccollister@gmail.com>
572a44
Date: Tue, 31 Dec 2013 14:37:32 -0600
572a44
Subject: [PATCH] journal: Add missing byte order conversions
572a44
572a44
Convert entry_array.items[0] to host byte order prior to passing it to
572a44
chain_cache_put().
572a44
572a44
[zj: also use le64toh in journal-verify.c]
572a44
572a44
https://bugs.freedesktop.org/show_bug.cgi?id=73194
572a44
---
572a44
 src/journal/journal-file.c   | 4 ++--
572a44
 src/journal/journal-verify.c | 6 +++---
572a44
 2 files changed, 5 insertions(+), 5 deletions(-)
572a44
572a44
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
572a44
index 9f04c58..748816a 100644
572a44
--- a/src/journal/journal-file.c
572a44
+++ b/src/journal/journal-file.c
572a44
@@ -1452,7 +1452,7 @@ static int generic_array_get(
572a44
 
572a44
 found:
572a44
         /* Let's cache this item for the next invocation */
572a44
-        chain_cache_put(f->chain_cache, ci, first, a, o->entry_array.items[0], t, i);
572a44
+        chain_cache_put(f->chain_cache, ci, first, a, le64toh(o->entry_array.items[0]), t, i);
572a44
 
572a44
         r = journal_file_move_to_object(f, OBJECT_ENTRY, p, &o);
572a44
         if (r < 0)
572a44
@@ -1685,7 +1685,7 @@ found:
572a44
                 return 0;
572a44
 
572a44
         /* Let's cache this item for the next invocation */
572a44
-        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);
572a44
+        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);
572a44
 
572a44
         if (subtract_one && i == 0)
572a44
                 p = last_p;
572a44
diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c
572a44
index 3405811..82b0f0a 100644
572a44
--- a/src/journal/journal-verify.c
572a44
+++ b/src/journal/journal-verify.c
572a44
@@ -249,12 +249,12 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
572a44
                 }
572a44
 
572a44
                 for (i = 0; i < journal_file_entry_array_n_items(o); i++)
572a44
-                        if (o->entry_array.items[i] != 0 &&
572a44
-                            !VALID64(o->entry_array.items[i])) {
572a44
+                        if (le64toh(o->entry_array.items[i]) != 0 &&
572a44
+                            !VALID64(le64toh(o->entry_array.items[i]))) {
572a44
                                 log_error(OFSfmt": invalid object entry array item (%"PRIu64"/%"PRIu64"): "OFSfmt,
572a44
                                           offset,
572a44
                                           i, journal_file_entry_array_n_items(o),
572a44
-                                          o->entry_array.items[i]);
572a44
+                                          le64toh(o->entry_array.items[i]));
572a44
                                 return -EBADMSG;
572a44
                         }
572a44