From ab8215a220b10dfb4b972ab2ab5a41b0a894a514 Mon Sep 17 00:00:00 2001 From: Tom Hromatka Date: Tue, 30 Mar 2021 18:54:06 +0000 Subject: [PATCH] cgset: Fix parsing of name/values with an '=' in the value MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reported-by: Santiago Ruano Rincón Signed-off-by: Tom Hromatka --- 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 9d4abbca..4e8c1e7e 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.47.2