From: Tom Hromatka Date: Sun, 5 Jan 2020 22:26:47 +0000 (-0700) Subject: api.c: Fix string truncation warning X-Git-Tag: v0.42~3^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6062531692e0135e938029caa7057d61d304c006;p=thirdparty%2Flibcgroup.git api.c: Fix string truncation warning This commit fixes this warning in api.c: api.c: In function ‘cgroup_delete_cgroup_ext’: api.c:2285:51: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] 2285 | snprintf(child_name, sizeof(child_name), "%s/%s", | ^ api.c:2285:4: note: ‘snprintf’ output 2 or more bytes (assuming 4097) into a destination of size 4096 2285 | snprintf(child_name, sizeof(child_name), "%s/%s", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2286 | cgroup_name, | ~~~~~~~~~~~~ 2287 | info.full_path + group_len); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Tom Hromatka --- diff --git a/src/api.c b/src/api.c index 5c347fad..30962fcc 100644 --- a/src/api.c +++ b/src/api.c @@ -2257,7 +2257,7 @@ static int cg_delete_cgroup_controller_recursive(char *cgroup_name, void *handle; struct cgroup_file_info info; int level, group_len; - char child_name[FILENAME_MAX]; + char child_name[FILENAME_MAX + 1]; cgroup_dbg("Recursively removing %s:%s\n", controller, cgroup_name);