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 <tom.hromatka@oracle.com>
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;