]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/journal/compress.c
journal: properly read unaligned le64 integers
[thirdparty/systemd.git] / src / journal / compress.c
index 7a79e566b8faa5cbd002cb30937fc24716847784..bfb75ae8c9dca8afeae36e07cf7c9765b2083d51 100644 (file)
@@ -26,6 +26,7 @@
 #include "sparse-endian.h"
 #include "string-table.h"
 #include "string-util.h"
+#include "unaligned.h"
 #include "util.h"
 
 #if HAVE_LZ4
@@ -101,7 +102,7 @@ int compress_blob_lz4(const void *src, uint64_t src_size,
         if (r <= 0)
                 return -ENOBUFS;
 
-        *(le64_t*) dst = htole64(src_size);
+        unaligned_write_le64(dst, src_size);
         *dst_size = r + 8;
 
         return 0;
@@ -187,8 +188,8 @@ int decompress_blob_lz4(const void *src, uint64_t src_size,
         if (src_size <= 8)
                 return -EBADMSG;
 
-        size = le64toh( *(le64_t*)src );
-        if (size < 0 || (unsigned) size != le64toh(*(le64_t*)src))
+        size = unaligned_read_le64(src);
+        if (size < 0 || (unsigned) size != unaligned_read_le64(src))
                 return -EFBIG;
         if ((size_t) size > *dst_alloc_size) {
                 out = realloc(*dst, size);