]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
src/api.c: fix TOCTOU in cg_get_procname_from_proc_cmdline()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Sat, 15 Jul 2023 06:34:11 +0000 (12:04 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 17 Jul 2023 17:26:56 +0000 (11:26 -0600)
commitd6d14e8b7ba28966dfd00a6471e9b2667b77705c
tree8fa644d0487df9a136cd82e8baae61b866b731bf
parent645ec049d1f39d1f441942c3e8af61f4c5b91460
src/api.c: fix TOCTOU in cg_get_procname_from_proc_cmdline()

Fix a TOCTOU issue, reported by Coverity tool:

CID 258283 (#1 of 1): Time of check time of use (TOCTOU)1.
fs_check_call: Calling function readlink to perform check on path

Coverity gets confused when a char array is re-used for constructing
different paths and complains about TOCTOU for unrelated paths, fix it
by using different char arrays for different path, as a side effect it
also improves the readability of the code.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/api.c