From: Tom Hromatka Date: Tue, 30 Mar 2021 18:54:06 +0000 (+0000) Subject: cgset: Fix parsing of name/values with an '=' in the value X-Git-Tag: v2.0.rc1~4^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab8215a220b10dfb4b972ab2ab5a41b0a894a514;p=thirdparty%2Flibcgroup.git cgset: Fix parsing of name/values with an '=' in the value 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 --- 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);