diff --git a/include/fluent-bit/flb_compat.h b/include/fluent-bit/flb_compat.h index 4b481086cfb..d98ec1350d6 100644 --- a/include/fluent-bit/flb_compat.h +++ b/include/fluent-bit/flb_compat.h @@ -27,6 +27,8 @@ #ifndef FLB_COMPAT_H #define FLB_COMPAT_H +#include + /* * libmonkey exposes compat macros for , which some platforms lack, * so include the header here. @@ -204,8 +206,14 @@ static inline uint32_t __attribute__((optimize("-O0"))) FLB_ALIGNED_DWORD_READ(u #endif #else -static inline uint32_t FLB_ALIGNED_DWORD_READ(unsigned char *source) { - return *((uint32_t *) source); +static inline uint32_t FLB_ALIGNED_DWORD_READ(unsigned char *source) +{ + uint32_t result; + + /* MessagePack extension payloads are not guaranteed to be aligned. */ + memcpy(&result, source, sizeof(result)); + + return result; } #endif