From: Mathieu Desnoyers Date: Tue, 26 Apr 2016 22:41:04 +0000 (-0400) Subject: Fix: endianness of integers received by filter X-Git-Url: http://git.efficios.com/?p=deliverable%2Flttng-modules.git;a=commitdiff_plain;h=bf1a91796a6809bac0c4dbd51d8eda0c75a14f23 Fix: endianness of integers received by filter We need to byteswap integers passed to the filter when they are tagged as being in an endianness which differs from the architecture endianness, so the integer comparisons make sense in terms of value rather than raw bytes for those fields. Signed-off-by: Mathieu Desnoyers --- diff --git a/probes/lttng-tracepoint-event-impl.h b/probes/lttng-tracepoint-event-impl.h index a87d146a..ba906ac4 100644 --- a/probes/lttng-tracepoint-event-impl.h +++ b/probes/lttng-tracepoint-event-impl.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -457,18 +458,24 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len, \ case 2: \ { \ union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != __BYTE_ORDER) \ + __swab16s(&__tmp.v); \ __ctf_tmp_int64 = (int64_t) __tmp.v; \ break; \ } \ case 4: \ { \ union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != __BYTE_ORDER) \ + __swab32s(&__tmp.v); \ __ctf_tmp_int64 = (int64_t) __tmp.v; \ break; \ } \ case 8: \ { \ union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != __BYTE_ORDER) \ + __swab64s(&__tmp.v); \ __ctf_tmp_int64 = (int64_t) __tmp.v; \ break; \ } \ @@ -488,18 +495,24 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len, \ case 2: \ { \ union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != __BYTE_ORDER) \ + __swab16s(&__tmp.v); \ __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ break; \ } \ case 4: \ { \ union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != __BYTE_ORDER) \ + __swab32s(&__tmp.v); \ __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ break; \ } \ case 8: \ { \ union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != __BYTE_ORDER) \ + __swab64s(&__tmp.v); \ __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ break; \ } \