]> 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:49:03 +0000 (12:49 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 24 Aug 2022 18:49:25 +0000 (12:49 -0600)
commit96db65fbb5296d4e66d1eb444c70d29b556e7eef
tree9b6e295925df5be362310ab6ca4d7a72c97f1650
parentc518abe761560c57b15541d85365602e0fce27d8
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