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 <santiago.ruano-rincon@imt-atlantique.fr>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
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);