From: Kamalesh Babulal Date: Sun, 18 Jun 2023 07:35:38 +0000 (+0530) Subject: tools/cgexec: fix uninitialized variable in find_scope_pid() X-Git-Tag: v3.1.0~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c719d9c858c5f9abc3be8ad00aff5571e2834a71;p=thirdparty%2Flibcgroup.git tools/cgexec: fix uninitialized variable in find_scope_pid() Fix uninitialized variable, reported by the Coverity tool: CID 321266: Uninitialized scalar variable (UNINIT) memset(), ctrl_name with every iteration, to avoid using the stale value or uninitialized values. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/src/tools/cgexec.c b/src/tools/cgexec.c index c0a2feff..863d4fb5 100644 --- a/src/tools/cgexec.c +++ b/src/tools/cgexec.c @@ -284,6 +284,8 @@ static pid_t find_scope_pid(pid_t pid) } while (fgets(buffer, FILENAME_MAX, pid_proc_fp)) { + memset(ctrl_name, '\0', sizeof(CONTROL_NAMELEN_MAX)); + /* read according to the cgroup mode */ if (strstr(buffer, "::")) ret = sscanf(buffer, "%d::%4096s\n", &idx, cgroup_name);