mirror of
https://github.com/systemd/systemd.git
synced 2024-11-27 20:23:36 +08:00
journal: properly read unaligned le64 integers
Fixes: #13051 Replaces: #13064
This commit is contained in:
parent
49aca3b152
commit
4094c4bfb7
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user