]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
api.c: add precision to fscanf(), in cgroup_populate_controllers()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Mon, 8 Aug 2022 17:01:31 +0000 (11:01 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 8 Aug 2022 17:01:50 +0000 (11:01 -0600)
commit5ea19ac2faa16c083c769ad068beee0e4cdc0aad
treeef4f9b185c75defaa7a9b54dbfb04e09bc4f2fa5
parent97aa5a67f9ed067a281cb77a06546ab09191064c
api.c: add precision to fscanf(), in cgroup_populate_controllers()

Fix calling risky function warning, reported by Coverity tool:

CID 258305 (#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 04169a9bef0ee77c18cd5a2e2d9f6e49f6057e32)
src/api.c