]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
tools/cgxset: check for delimiter in name_value string
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Sat, 4 Mar 2023 06:34:10 +0000 (06:34 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 6 Mar 2023 15:23:13 +0000 (08:23 -0700)
commitee9feddfe5192c3b6a078d7568d46a5d3c862512
tree1b2186da60a9ec929fda5ea1b91082b2c75526f1
parent5cc1fda4070729520f350b61c931de706123bf65
tools/cgxset: 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>
(cherry picked from commit bc414f494686c3bc66f2747b61c80a4f6e9118f5)
src/tools/cgxset.c