From 74f286be45611aa0a3e0a8fedfdee6c254a97ee6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 7 Apr 2021 13:01:44 -0400 Subject: [PATCH] Fix: sessiond: error accounting: wrong sizeof argument cpu_counters MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 1452205 Wrong sizeof argument The wrong sizeof value is used in an expression or as argument to a function. The result is an incorrect value that may cause unexpected program behaviors. In create_uid_accounting_entry: The sizeof operator is invoked on the wrong argument (CWE-569) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau Change-Id: I1912964bd1579f3b1ff013000848c28cea6a9d52 --- src/bin/lttng-sessiond/event-notifier-error-accounting.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng-sessiond/event-notifier-error-accounting.c b/src/bin/lttng-sessiond/event-notifier-error-accounting.c index cb8380251..aee82742a 100644 --- a/src/bin/lttng-sessiond/event-notifier-error-accounting.c +++ b/src/bin/lttng-sessiond/event-notifier-error-accounting.c @@ -223,11 +223,11 @@ struct error_account_entry *create_uid_accounting_entry( cpu_counter_fds[i] = -1; } - cpu_counters = zmalloc(entry->nr_counter_cpu_fds * sizeof(**cpu_counters)); + cpu_counters = zmalloc(entry->nr_counter_cpu_fds * sizeof(struct lttng_ust_abi_object_data *)); if (!cpu_counters) { PERROR("Failed to allocate event notifier error counter lttng_ust_abi_object_data array: application uid = %d, application name = '%s', pid = %d, allocation size = %zu", (int) app->uid, app->name, (int) app->pid, - entry->nr_counter_cpu_fds * sizeof(**cpu_counters)); + entry->nr_counter_cpu_fds * sizeof(struct lttng_ust_abi_object_data *)); ret = -1; goto error_counter_cpus_alloc; } -- 2.34.1