journald: use unaligned_read instead of memcpy
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 14 May 2017 02:42:08 +0000 (22:42 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 May 2017 15:40:53 +0000 (11:40 -0400)
src/journal/journald-native.c

index c9bf383..d839e04 100644 (file)
@@ -40,6 +40,7 @@
 #include "selinux-util.h"
 #include "socket-util.h"
 #include "string-util.h"
+#include "unaligned.h"
 
 bool valid_user_field(const char *p, size_t l, bool allow_protected) {
         const char *a;
@@ -218,7 +219,6 @@ void server_process_native_message(
                         p = e + 1;
                         continue;
                 } else {
-                        le64_t l_le;
                         uint64_t l;
                         char *k;
 
@@ -227,8 +227,7 @@ void server_process_native_message(
                                 break;
                         }
 
-                        memcpy(&l_le, e + 1, sizeof(uint64_t));
-                        l = le64toh(l_le);
+                        l = unaligned_read_le64(e + 1);
 
                         if (l > DATA_SIZE_MAX) {
                                 log_debug("Received binary data block of %"PRIu64" bytes is too large, ignoring.", l);