X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fchannel.cpp;h=5bef795589d75c4349cdf05fe31b65a77369698f;hb=de5abcb02431896a1827dff5d3376e1f2e124cd7;hp=db8d6fdec0c7130a738508c6a71f44a4b0e6bdbd;hpb=999af9c1150784f8676c6fce0764772d2314854a;p=lttng-tools.git diff --git a/src/common/channel.cpp b/src/common/channel.cpp index db8d6fdec..5bef79558 100644 --- a/src/common/channel.cpp +++ b/src/common/channel.cpp @@ -5,18 +5,16 @@ * */ -#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include static enum lttng_error_code flatten_lttng_channels( struct lttng_dynamic_pointer_array *channels, @@ -39,7 +37,7 @@ struct lttng_channel *lttng_channel_copy(const struct lttng_channel *src) struct lttng_channel_extended *extended = nullptr; struct lttng_channel *channel = nullptr, *ret = nullptr; - channel = (struct lttng_channel *) zmalloc(sizeof(*channel)); + channel = zmalloc(); if (!channel) { goto end; } @@ -47,8 +45,7 @@ struct lttng_channel *lttng_channel_copy(const struct lttng_channel *src) *channel = *src; if (src->attr.extended.ptr) { - extended = (struct lttng_channel_extended *) zmalloc( - sizeof(*extended)); + extended = zmalloc(); if (!extended) { goto end; } @@ -73,15 +70,13 @@ struct lttng_channel *lttng_channel_create_internal(void) struct lttng_channel *local_channel = nullptr, *ret = nullptr; struct lttng_channel_extended *extended = nullptr; - local_channel = (struct lttng_channel *) zmalloc( - sizeof(struct lttng_channel)); + local_channel = zmalloc(); if (!local_channel) { goto end; } /* Extended struct */ - extended = (struct lttng_channel_extended *) zmalloc( - sizeof(*extended)); + extended = zmalloc(); if (!extended) { goto end; } @@ -146,11 +141,6 @@ ssize_t lttng_channel_create_from_buffer(const struct lttng_buffer_view *view, lttng_buffer_view_from_view(view, offset, channel_comm->name_len); - if (channel_comm->name_len > LTTNG_SYMBOL_NAME_LEN - 1) { - ret = -1; - goto end; - } - name = name_view.data; if (!lttng_buffer_view_contains_string( &name_view, name, channel_comm->name_len)) { @@ -158,7 +148,12 @@ ssize_t lttng_channel_create_from_buffer(const struct lttng_buffer_view *view, goto end; } - strcpy(local_channel->name, name); + ret = lttng_strncpy(local_channel->name, name, + sizeof(local_channel->name)); + if (ret) { + goto end; + } + offset += channel_comm->name_len; } @@ -198,7 +193,7 @@ int lttng_channel_serialize( { int ret; size_t name_len; - struct lttng_channel_comm channel_comm = { 0 }; + struct lttng_channel_comm channel_comm = {}; struct lttng_channel_extended *extended; assert(channel);