]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
wrapper.c: Fix buffer not null terminated Coverity warning
authorTom Hromatka <tom.hromatka@oracle.com>
Tue, 7 Jan 2020 18:53:23 +0000 (11:53 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 8 Jan 2020 15:01:39 +0000 (08:01 -0700)
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 <tom.hromatka@oracle.com>
src/wrapper.c

index 4f238367bfae6b2ad443a57e5bc78f12c726e897..ee98ac5c70d998d5617883c4a095ca6d62e7f039 100644 (file)
@@ -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;
                }