From 856b414b638f61c09f57227eedc7ca891049fd19 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 16 Mar 2022 11:56:21 -0400 Subject: [PATCH] Fix: event: erroneous bound check on perf counter name size MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The wrong size if used when initializing a perf counter name from a payload. The destination size must be used to prevent out of bound writes. Signed-off-by: Jérémie Galarneau Change-Id: I8ea41d30815bd2c02bb2ad8b01e8cecd2d6549a8 --- src/common/event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/event.c b/src/common/event.c index f336875ae..484fde26f 100644 --- a/src/common/event.c +++ b/src/common/event.c @@ -1040,7 +1040,8 @@ static ssize_t lttng_event_context_perf_counter_populate_from_payload( goto end; } - ret = lttng_strncpy(event_ctx->u.perf_counter.name, name, name_len); + ret = lttng_strncpy(event_ctx->u.perf_counter.name, name, + sizeof(event_ctx->u.perf_counter.name)); if (ret) { consumed = -1; goto end; -- 2.34.1