]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
tools/cgexec: fix uninitialized variable in find_scope_pid()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Sun, 18 Jun 2023 07:35:38 +0000 (13:05 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 21 Jun 2023 16:16:25 +0000 (10:16 -0600)
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 <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/tools/cgexec.c

index c0a2feffa16ac9b3cc87c1f91c9d181856dea4d0..863d4fb58d48ebab1b5cd92d44f774aaa82a4ad2 100644 (file)
@@ -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);