]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
tools/cgset: check for delimiter in name_value string
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Sat, 4 Mar 2023 06:20:53 +0000 (06:20 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 6 Mar 2023 15:21:04 +0000 (08:21 -0700)
commitb29c68bb5d36523e051f7ec0d92b2db93de26bf2
tree3629020d66182f4c115af53cb40e170615a7b164
parent81f12364c78a8f7f1e90b5ce90e9f02cf057c623
tools/cgset: check for delimiter in name_value string

While parsing -r option for name, and value pairs, we rely on strtok()
to return NULL, when there is no delimiter and lhf/rhf can't be mapped
into the name, and value tokens. This assumption is not true, strtok()
returns the whole string when it doesn't find the delimiter. Operating
under this assumption also segfaults later in the code.  Fix it, by
checking for the presence of a delimiter in the passed name_value_str
in parse_r_flag().  This also initializes the pointer to NULL, to
avoid reading them before assignment in the error path.

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