Fix a build warning:
cgcreate.c: In function ‘create_systemd_scope’:
cgcreate.c:81:17: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-truncation]
81 | strncpy(slice, cg->name, len);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cgcreate.c:80:23: note: length computed here
80 | len = strlen(cg->name) - strlen(scope);
fix it by using, length of destination in the strncpy().
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
goto err;
}
len = strlen(cg->name) - strlen(scope);
- strncpy(slice, cg->name, len);
+ strncpy(slice, cg->name, FILENAME_MAX - 1);
slice[len] = '\0';
scope++;