From: Vsevolod Stakhov Date: Sat, 5 May 2018 11:09:42 +0000 (+0100) Subject: [Minor] Sync from libucl X-Git-Tag: 1.7.5~70 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=22bac56f258e2afcda6d2104fc5e2aaedf8c123b;p=rspamd.git [Minor] Sync from libucl --- diff --git a/contrib/libucl/ucl_msgpack.c b/contrib/libucl/ucl_msgpack.c index 96f4809f8..bd7c3a1ce 100644 --- a/contrib/libucl/ucl_msgpack.c +++ b/contrib/libucl/ucl_msgpack.c @@ -1423,6 +1423,10 @@ ucl_msgpack_parse_int (struct ucl_parser *parser, int16_t iv16; int32_t iv32; int64_t iv64; + uint16_t uiv16; + uint32_t uiv32; + uint64_t uiv64; + if (len > remain) { return -1; @@ -1455,7 +1459,9 @@ ucl_msgpack_parse_int (struct ucl_parser *parser, len = 2; break; case msgpack_uint16: - obj->value.iv = FROM_BE16 (*(uint16_t *)pos); + memcpy (&uiv16, pos, sizeof (uiv16)); + uiv16 = FROM_BE16 (uiv16); + obj->value.iv = uiv16; len = 2; break; case msgpack_int32: @@ -1465,7 +1471,9 @@ ucl_msgpack_parse_int (struct ucl_parser *parser, len = 4; break; case msgpack_uint32: - obj->value.iv = FROM_BE32 (*(uint32_t *)pos); + memcpy(&uiv32, pos, sizeof(uiv32)); + uiv32 = FROM_BE32(uiv32); + obj->value.iv = uiv32; len = 4; break; case msgpack_int64: @@ -1475,7 +1483,9 @@ ucl_msgpack_parse_int (struct ucl_parser *parser, len = 8; break; case msgpack_uint64: - obj->value.iv = FROM_BE64 (*(uint64_t *)pos); + memcpy(&uiv64, pos, sizeof(uiv64)); + uiv64 = FROM_BE64(uiv64); + obj->value.iv = uiv64; len = 8; break; default: @@ -1498,6 +1508,7 @@ ucl_msgpack_parse_float (struct ucl_parser *parser, uint32_t i; float f; } d; + uint64_t uiv64; if (len > remain) { return -1; @@ -1507,13 +1518,16 @@ ucl_msgpack_parse_float (struct ucl_parser *parser, switch (fmt) { case msgpack_float32: - d.i = FROM_BE32 (*(uint32_t *)pos); + memcpy(&d.i, pos, sizeof(d.i)); + d.i = FROM_BE32(d.i); /* XXX: can be slow */ obj->value.dv = d.f; len = 4; break; case msgpack_float64: - obj->value.iv = FROM_BE64 (*(uint64_t *)pos); + memcpy(&uiv64, pos, sizeof(uiv64)); + uiv64 = FROM_BE64(uiv64); + obj->value.iv = uiv64; len = 8; break; default: diff --git a/contrib/libucl/ucl_sexp.c b/contrib/libucl/ucl_sexp.c index c4ad75a18..1ad93d234 100644 --- a/contrib/libucl/ucl_sexp.c +++ b/contrib/libucl/ucl_sexp.c @@ -26,6 +26,7 @@ #include "config.h" #endif +#include #include "ucl.h" #include "ucl_internal.h" #include "utlist.h"