From feac72042ef1572189d4280a4f151ce049ac2b1e Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 27 Jul 2022 10:54:53 -0400 Subject: [PATCH] fix: removed accidental VLA in _get_num_possible_cpus() The LTTNG_UST_PAGE_SIZE define can either point to a literal value or the sysconf() function making buf[] a VLA. Replace this by a cpumask specifc define that will always be a literal value. Change-Id: I8d329f314878e8018939f979861918969e3ec8ac Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- src/common/smp.c | 7 +++---- src/common/smp.h | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/common/smp.c b/src/common/smp.c index d7ba23c4..980947cf 100644 --- a/src/common/smp.c +++ b/src/common/smp.c @@ -10,13 +10,13 @@ #include #include #include +#include #include #include #include #include -#include "common/align.h" #include "common/logging.h" #include "common/smp.h" @@ -190,11 +190,10 @@ error: static void _get_num_possible_cpus(void) { int ret; - int buf_len = LTTNG_UST_PAGE_SIZE; - char buf[buf_len]; + char buf[LTTNG_UST_CPUMASK_SIZE]; /* Get the possible cpu mask from sysfs, fallback to sysconf. */ - ret = get_possible_cpu_mask_from_sysfs((char *) &buf, buf_len); + ret = get_possible_cpu_mask_from_sysfs((char *) &buf, LTTNG_UST_CPUMASK_SIZE); if (ret <= 0) goto fallback; diff --git a/src/common/smp.h b/src/common/smp.h index b6dd5707..51fbd2d7 100644 --- a/src/common/smp.h +++ b/src/common/smp.h @@ -7,6 +7,8 @@ #ifndef _UST_COMMON_SMP_H #define _UST_COMMON_SMP_H +#define LTTNG_UST_CPUMASK_SIZE 4096 + /* * Get the CPU possible mask string from sysfs. * -- 2.34.1