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 <tom.hroma...@oracle.com>
---
 src/api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/api.c b/src/api.c
index 30555f124e74..5c347fadbd83 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;
 
-- 
1.8.3.1



_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to