From 1eb905fec003476f9fea9990ad4c9692925defcf Mon Sep 17 00:00:00 2001 From: Tom Hromatka Date: Sun, 5 Jan 2020 15:17:09 -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_value_begin’: api.c:4114:47: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] 4114 | snprintf(stat_file, sizeof(stat_file), "%s/%s", stat_path, | ^ api.c:4114:2: note: ‘snprintf’ output 2 or more bytes (assuming 4097) into a destination of size 4096 4114 | snprintf(stat_file, sizeof(stat_file), "%s/%s", stat_path, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | name); | ~~~~~ 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 30555f12..5c347fad 100644 --- a/src/api.c +++ b/src/api.c @@ -4098,7 +4098,7 @@ int cgroup_read_value_begin(const char *controller, const char *path, { int ret = 0; char *ret_c = NULL; - char stat_file[FILENAME_MAX]; + char stat_file[FILENAME_MAX + sizeof(name)]; char stat_path[FILENAME_MAX]; FILE *fp; -- 2.47.2