From bf1a91796a6809bac0c4dbd51d8eda0c75a14f23 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 26 Apr 2016 18:41:04 -0400 Subject: [PATCH] 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 --- probes/lttng-tracepoint-event-impl.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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; \ } \ -- 2.34.1