X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=probes%2Flttng-events.h;h=d486994f3a0c2202741037c8ef68ffe5ebd16bc5;hb=edb5c2da83545004c5f556accb79d010a6b1e3a9;hp=54a451e53388eda82d279d3ec1a98e6a398314f0;hpb=d0255731fe93baede90f26d19aa4388403973554;p=lttng-modules.git diff --git a/probes/lttng-events.h b/probes/lttng-events.h index 54a451e5..d486994f 100644 --- a/probes/lttng-events.h +++ b/probes/lttng-events.h @@ -341,11 +341,13 @@ static __used struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = { __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1; /* - * strlen_user includes \0. If returns 0, it faulted. + * strlen_user includes \0. If returns 0, it faulted, so we set size to + * 1 (\0 only). */ #undef __string_from_user #define __string_from_user(_item, _src) \ - __event_len += __dynamic_len[__dynamic_len_idx++] = strlen_user(_src); + __event_len += __dynamic_len[__dynamic_len_idx++] = \ + max_t(size_t, strlen_user(_src), 1); #undef TP_PROTO #define TP_PROTO(args...) args @@ -543,9 +545,7 @@ __assign_##dest##_2: \ goto __end_field_##dest; /* - * If string length is zero, this means reading the string faulted, so - * we simply put a \0. If string length is larger than 0, it is the - * string length including the final \0. + * The string length including the final \0. */ #undef tp_copy_string_from_user #define tp_copy_string_from_user(dest, src) \ @@ -557,7 +557,7 @@ __assign_##dest##_2: \ (void) __typemap.dest; \ lib_ring_buffer_align_ctx(&__ctx, ltt_alignof(__typemap.dest));\ __ustrlen = __get_dynamic_array_len(dest); \ - if (likely(__ustrlen) > 1) { \ + if (likely(__ustrlen > 1)) { \ __chan->ops->event_write_from_user(&__ctx, src, \ __ustrlen - 1); \ } \