From b6f635ef8dc264838bb26733349d6df6595124cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 13 Sep 2023 00:08:59 +0200 Subject: [PATCH] lscpu: remove usage of VLA MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Variable-length-arrays are susceptible to security issues, avoid them. Signed-off-by: Thomas Weißschuh --- sys-utils/lscpu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 8333dcbea6..97adaa23ad 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -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 -- 2.47.2