Fix parsing of name/value pairs that contain an '=' character in the value string. For example, the io.max setting utilizes the '=' character: cgset -r io.max="8:16 wbps=1024" foo
Fixes: https://github.com/libcgroup/libcgroup/issues/33 Signed-off-by: Tom Hromatka <tom.hroma...@oracle.com> --- src/tools/cgset.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tools/cgset.c b/src/tools/cgset.c index 9d4abbca94b7..4e8c1e7e1aa4 100644 --- a/src/tools/cgset.c +++ b/src/tools/cgset.c @@ -100,8 +100,13 @@ static int parse_r_flag(const char * const program_name, strncpy(name_value->name, buf, FILENAME_MAX); name_value->name[FILENAME_MAX-1] = '\0'; - buf = strtok(NULL, "="); - if (buf == NULL) { + buf = strchr(name_value_str, '='); + /* we don't need to check the return value of strchr because we + * know there's already an '=' character in the string. + */ + buf++; + + if (strlen(buf) == 0) { fprintf(stderr, "%s: " "wrong parameter of option -r: %s\n", program_name, optarg); -- 2.26.2 _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel