From: Kamalesh Babulal Date: Fri, 14 Apr 2023 15:30:01 +0000 (+0000) Subject: tools/cgxget: fix segfault in free path X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=480176e2f27ae2e0b0b9c7e0afa8872e82c60a61;p=thirdparty%2Flibcgroup.git tools/cgxget: fix segfault in free path cgxget tool crashes, when passing basic operations such as multiple cgroups as arguments or invalid parameters, it turns out the address of struct cgroup passed for cgroup_free() has been invalid. $ sudo ./src/tools/cgxget -1 -r cpu.shares a b Segmentation fault (core dumped) $ sudo ./src/tools/cgxget -1 cpu.shares a b Segmentation fault (core dumped) this patch fixes it by passing the right address of the struct cgroup[] to cgroup_free(). Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka (cherry picked from commit a1299d6cd01fbff653a3fe919a67ea86483a054e) --- diff --git a/src/tools/cgxget.c b/src/tools/cgxget.c index 225e3a63..a9eb0fd2 100644 --- a/src/tools/cgxget.c +++ b/src/tools/cgxget.c @@ -823,7 +823,7 @@ out: * Free the old list. */ for (i = 0; i < cg_list_len; i++) - cgroup_free(cg_list[i]); + cgroup_free(&(*cg_list)[i]); *cg_list = cg_converted_list; }