]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
api.c: fix string termination in cgroup_get_procname_from_procfs()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 20 Jul 2022 17:16:15 +0000 (11:16 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 20 Jul 2022 17:16:20 +0000 (11:16 -0600)
commit9612128edd03ba5085cd0c169685915cd7d6e2c8
tree010350b5e27709047506a03259a3e382a20aaf17
parentcab3181782f590d6382ce1bcad2de5688c341b14
api.c: fix string termination in cgroup_get_procname_from_procfs()

Fix non-terminated string warning, reported by Coverity tool:

CID 258273 (#2 of 2): String not null terminated (STRING_NULL)6.
string_null: Passing unterminated string buf to strdup, which expects a
null-terminated string.

use snprintf() instead of sprintf(), to string terminate
cgroup_get_procname_from_procfs().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 422c0300583a7b450838e4936ba0d51584354831)
src/api.c