From cdd4b115b10c3492df0a27880e4d8d41d167fe82 Mon Sep 17 00:00:00 2001 From: Tom Hromatka Date: Tue, 7 Jan 2020 11:53:23 -0700 Subject: [PATCH] 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 --- src/wrapper.c | 1 + 1 file changed, 1 insertion(+) 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; } -- 2.47.2