dryang / rpms / systemd

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