]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
api: null terminate readlink buffer in cg_get_procname_from_proc_cmdline()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 20 Jul 2022 17:22:01 +0000 (11:22 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 20 Jul 2022 17:22:06 +0000 (11:22 -0600)
commit23bdfd2326a01675a0eac9ab7b601b4a505d219c
tree182992b0b1540b8a9a16deabc9399d1abfa0bf87
parent422c0300583a7b450838e4936ba0d51584354831
api: null terminate readlink buffer in cg_get_procname_from_proc_cmdline()

Fix readlink buffer null termination warning, reported by Coverity tool:

CID 258276 (#1 of 1): String not null terminated (STRING_NULL).
string_null: Passing unterminated string buf_cwd to strcat, which
expects a null-terminated string.

As per the man pages (man 2 readlink):
"readlink() does not append a null byte to buf.  It  will  (silently)
truncate the contents (to a length of bufsiz characters), in case the
buffer is too small to hold all of the contents."

Explicitly null terminate the buffer passed to readlink() in
cg_get_procname_from_proc_cmdline().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/api.c