]> 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:44:47 +0000 (12:44 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 24 Aug 2022 18:44:51 +0000 (12:44 -0600)
commit8b9665c29cb812c255687d6e5cb5262a6fe30a40
treecb1f4e5c87687041a1d33942ae47940fc4518ad7
parentdb2039f6ad75988e0aad3f5306d5d8c02aa4b040
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>
src/api.c