All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: Fix strncpy() fortify warning
@ 2022-10-27 11:33 Rong Tao
  2022-10-27 20:09 ` Andrii Nakryiko
  0 siblings, 1 reply; 17+ messages in thread
From: Rong Tao @ 2022-10-27 11:33 UTC (permalink / raw)
  Cc: Rong Tao, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Mykola Lysenko,
	Shuah Khan,
	open list:BPF [GENERAL] (Safe Dynamic Programs and Tools),
	open list:KERNEL SELFTEST FRAMEWORK, open list

From: Rong Tao <rongtao@cestc.cn>

Compile samples/bpf, error:
$ cd samples/bpf
$ make
...
In function ‘__enable_controllers’:
samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:80:17: warning: ‘strncpy’ specified bound 4097 equals destination size [-Wstringop-truncation]
   80 |                 strncpy(enable, controllers, sizeof(enable));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
 tools/testing/selftests/bpf/cgroup_helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/cgroup_helpers.c b/tools/testing/selftests/bpf/cgroup_helpers.c
index e914cc45b766..a70e873b267e 100644
--- a/tools/testing/selftests/bpf/cgroup_helpers.c
+++ b/tools/testing/selftests/bpf/cgroup_helpers.c
@@ -77,7 +77,7 @@ static int __enable_controllers(const char *cgroup_path, const char *controllers
 		enable[len] = 0;
 		close(fd);
 	} else {
-		strncpy(enable, controllers, sizeof(enable));
+		strncpy(enable, controllers, sizeof(enable) - 1);
 	}
 
 	snprintf(path, sizeof(path), "%s/cgroup.subtree_control", cgroup_path);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-11-04 22:52 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27 11:33 [PATCH bpf-next] selftests/bpf: Fix strncpy() fortify warning Rong Tao
2022-10-27 20:09 ` Andrii Nakryiko
2022-10-28  0:26   ` Re: [PATCH] " Rong Tao
2022-10-28 17:08     ` Andrii Nakryiko
2022-10-29  2:59       ` [PATCH bpf-next] " Rong Tao
2022-10-29 12:23         ` David Laight
2022-11-01  9:25           ` Rong Tao
2022-11-01  9:27             ` David Laight
2022-11-01 12:21               ` Rong Tao
2022-11-01 13:56                 ` Daniel Borkmann
2022-11-01 14:23                   ` Rong Tao
2022-11-01 15:46                     ` Daniel Borkmann
2022-11-02 12:59                       ` [PATCH bpf-next] selftests/bpf: cgroup_helpers.c: " Rong Tao
2022-11-03 18:45                         ` Andrii Nakryiko
2022-11-04  1:27                           ` Rong Tao
2022-11-04 22:50                             ` patchwork-bot+netdevbpf
2022-10-29  3:07       ` [RESEND PATCH bpf-next] selftests/bpf: " Rong Tao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.