From: Tom Hromatka Date: Tue, 7 Jan 2020 18:53:23 +0000 (-0700) Subject: wrapper.c: Fix buffer not null terminated Coverity warning X-Git-Tag: v0.42~3^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cdd4b115b10c3492df0a27880e4d8d41d167fe82;p=thirdparty%2Flibcgroup.git wrapper.c: Fix buffer not null terminated Coverity warning This patch fixes the following Coverity warning: CID 1412155 (#1 of 1): Buffer not null terminated (BUFFER_SIZE_WARNING)4. buffer_size_warning: Calling strncpy with a maximum size argument of 100 bytes on destination array val->value of size 100 bytes might leave the destination string unterminated. Signed-off-by: Tom Hromatka --- diff --git a/src/wrapper.c b/src/wrapper.c index 4f238367..ee98ac5c 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -407,6 +407,7 @@ int cgroup_set_value_string(struct cgroup_controller *controller, struct control_value *val = controller->values[i]; if (!strcmp(val->name, name)) { strncpy(val->value, value, CG_VALUE_MAX); + val->value[sizeof(val->value)-1] = '\0'; val->dirty = true; return 0; }