From dc212c5a6c7ff4e4455968ea9ee4d3af03a2972d Mon Sep 17 00:00:00 2001 From: Tom Hromatka Date: Tue, 29 Jul 2025 16:07:27 +0000 Subject: [PATCH] api: Fix clang warning Fix the following warnings from clang by reducing the size passed to strncat by 1 as recommended by clang. api.c:3784:24: warning: the value of the size argument in 'strncat' is too large, might lead to a buffer overflow [-Wstrncat-size] 3784 | strncat(path, d_name, sizeof(path) - strlen(path)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ api.c:3784:24: note: change the argument to be the free space in the destination buffer minus the terminating null byte 3784 | strncat(path, d_name, sizeof(path) - strlen(path)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ | sizeof(path) - strlen(path) - 1 Signed-off-by: Tom Hromatka Signed-off-by: Kamalesh Babulal --- src/api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api.c b/src/api.c index 435d3679..c2f07fc3 100644 --- a/src/api.c +++ b/src/api.c @@ -3781,7 +3781,7 @@ int cgroup_fill_cgc(struct dirent *ctrl_dir, struct cgroup *cgrp, struct cgroup_ * sort of a flag, but this is fine for now. */ cg_build_path_locked(cgrp->name, path, cg_mount_table[cg_index].name); - strncat(path, d_name, sizeof(path) - strlen(path)); + strncat(path, d_name, sizeof(path) - strlen(path) - 1); error = stat(path, &stat_buffer); if (error) { -- 2.47.2