fix: removed accidental VLA in _get_num_possible_cpus()
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 27 Jul 2022 14:54:53 +0000 (10:54 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 27 Jul 2022 15:25:30 +0000 (11:25 -0400)
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 <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
libringbuffer/smp.c
libringbuffer/smp.h

index 8b66b9e83fd08b88c6b70798000781898af1a562..966556dcee15cf38b0a4b6e86d1f47ccd878169b 100644 (file)
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#include "align.h"
 #include "smp.h"
 #include "usterr-signal-safe.h"
 
@@ -206,11 +207,10 @@ error:
 void _get_num_possible_cpus(void)
 {
        int ret;
-       int buf_len = sysconf(_SC_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;
 
index 1a880994bbe67a656c1e0ff499de67939df0390a..0db9e8418852129eeddea55c87bb24f644023638 100644 (file)
@@ -31,6 +31,8 @@
 
 extern int __num_possible_cpus;
 
+#define LTTNG_UST_CPUMASK_SIZE 4096
+
 /*
  * Get the CPU possible mask string from sysfs.
  *
This page took 0.026714 seconds and 4 git commands to generate.