From 017932c3df8b8e6dcb72643b4114c1296f801a7e Mon Sep 17 00:00:00 2001 From: Tom Hromatka Date: Sun, 5 Jan 2020 15:13:51 -0700 Subject: [PATCH] api.c: Fix string truncation warning MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This commit fixes this warning in api.c: api.c: In function ‘cgroup_read_stats_begin’: api.c:4189:47: warning: ‘.stat’ directive output may be truncated writing 5 bytes into a region of size between 0 and 4095 [-Wformat-truncation=] 4189 | snprintf(stat_file, sizeof(stat_file), "%s/%s.stat", stat_path, | ^~~~~ api.c:4189:2: note: ‘snprintf’ output 7 or more bytes (assuming 4102) into a destination of size 4096 4189 | snprintf(stat_file, sizeof(stat_file), "%s/%s.stat", stat_path, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | controller); | ~~~~~~~~~~~ Signed-off-by: Tom Hromatka --- src/api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api.c b/src/api.c index 0a09e6fe..30555f12 100644 --- a/src/api.c +++ b/src/api.c @@ -4173,7 +4173,7 @@ int cgroup_read_stats_begin(const char *controller, const char *path, void **handle, struct cgroup_stat *cgroup_stat) { int ret = 0; - char stat_file[FILENAME_MAX]; + char stat_file[FILENAME_MAX + sizeof(".stat")]; char stat_path[FILENAME_MAX]; FILE *fp; -- 2.47.2