]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
api.c: add precision to fscanf(), in cgroup_get_all_controller_next()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Mon, 8 Aug 2022 16:37:25 +0000 (10:37 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 8 Aug 2022 16:37:28 +0000 (10:37 -0600)
commitaad6b721131737bc4ac872793dbf42e0b0ae7fde
tree7799682259ea85cadae570323938b31cf65a727d
parentbe729ca7b413ed0633d6b8c8f27d765e1adb31e1
api.c: add precision to fscanf(), in cgroup_get_all_controller_next()

Fix calling risky function warning, reported by Coverity tool:

CID 258300 (#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
MAX_CGROUP_TYPE_NAMELEN 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 4036f4fe4334572a4669dfece01ff24dbdd56477)
src/api.c