]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
api.c: fix TOCTOU in cg_chmod_path()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 24 Aug 2022 18:46:35 +0000 (12:46 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 24 Aug 2022 18:46:39 +0000 (12:46 -0600)
commitc812c8f15171ef182fdb1b0b92478bf5907b4e03
tree73028372d041a866460feace26a99c9eb45a7303
parent3966b27e44c0fab07af16992d5d66a50d59adafd
api.c: fix TOCTOU in cg_chmod_path()

Fix TOCTOU warning, reported by Coverity Tool:

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

in cg_chmod_path(), the file name is stat() and not immediately followed
by the file operation. One way to fix it, open the file and use the file
descriptor to manipulate the file.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 8b9665c29cb812c255687d6e5cb5262a6fe30a40)
src/api.c