Blob Blame History Raw
From a7637ee87936b9530b0ed56b5520a3e22bd04f94 Mon Sep 17 00:00:00 2001
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Date: Wed, 22 Mar 2017 03:36:50 +0100
Subject: [PATCH] basic/journal-importer: Fix unaligned access in
 get_data_size() (#5622)

(cherry picked from commit f652c62d71a412704efe7c73c2066d1baaf83456)
---
 src/basic/journal-importer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/basic/journal-importer.c b/src/basic/journal-importer.c
index d25fd358e8..66119d2de1 100644
--- a/src/basic/journal-importer.c
+++ b/src/basic/journal-importer.c
@@ -24,6 +24,7 @@
 #include "fd-util.h"
 #include "parse-util.h"
 #include "string-util.h"
+#include "unaligned.h"
 
 enum {
         IMPORTER_STATE_LINE = 0,    /* waiting to read, or reading line */
@@ -203,7 +204,7 @@ static int get_data_size(JournalImporter *imp) {
         if (r <= 0)
                 return r;
 
-        imp->data_size = le64toh( *(uint64_t *) data );
+        imp->data_size = unaligned_read_le64(data);
         if (imp->data_size > DATA_SIZE_MAX) {
                 log_error("Stream declares field with size %zu > DATA_SIZE_MAX = %u",
                           imp->data_size, DATA_SIZE_MAX);