]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
api.c: add precision to fscanf(), in cgroup_get_current_controller_path()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 10 Aug 2022 16:59:19 +0000 (10:59 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 10 Aug 2022 17:00:03 +0000 (11:00 -0600)
commita56103d2f833e3a1ba532d2a8b0b222fd1cd1bfd
tree130972fe54b0f47df44b312b0a29649464bc8086
parent5ea19ac2faa16c083c769ad068beee0e4cdc0aad
api.c: add precision to fscanf(), in cgroup_get_current_controller_path()

Fix calling risky function warning, reported by Coverity tool:

CID 258301 (#1 of 1): Calling risky function
(DC.STREAM_BUFFER)dont_call: fscanf assumes an arbitrarily long string,
so callers must use correct precision specifiers or never use fscanf.

As per secure coding standard, using '%s' in the fscanf() is not
recommend, hence fix it by using the precision of macro
FILENAME_MAX borrowed from Linux Kernel for the maximum
allowed controller/subsys_name length.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit ac05eb49c498aa5047070a4620456fa7a10e1910)
TJH: Small fix in the commit comment.
src/api.c