]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: remove usage of VLA
authorThomas Weißschuh <thomas@t-8ch.de>
Tue, 12 Sep 2023 22:08:59 +0000 (00:08 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Wed, 13 Sep 2023 06:37:02 +0000 (08:37 +0200)
Variable-length-arrays are susceptible to security issues, avoid them.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
sys-utils/lscpu.c

index 8333dcbea628bfd67ceb69b6e19184c67450e6e6..97adaa23ad7b77152f2a8c8067ca85b3ea24b0a6 100644 (file)
@@ -855,13 +855,15 @@ print_cpuset(struct lscpu_cxt *cxt,
             const char *key, cpu_set_t *set)
 {
        size_t setbuflen = 7 * cxt->maxcpus;
-       char setbuf[setbuflen], *p;
+       char *setbuf, *p;
 
        assert(set);
        assert(key);
        assert(tb);
        assert(cxt);
 
+       setbuf = xmalloc(setbuflen);
+
        if (cxt->hex) {
                p = cpumask_create(setbuf, setbuflen, set, cxt->setsize);
                add_summary_s(tb, sec, key, p);
@@ -869,6 +871,8 @@ print_cpuset(struct lscpu_cxt *cxt,
                p = cpulist_create(setbuf, setbuflen, set, cxt->setsize);
                add_summary_s(tb, sec, key, p);
        }
+
+       free(setbuf);
 }
 
 static void