Message ID | tencent_D977F40871CDA0474822CBF7324D25F9B505@qq.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [RESEND,bpf-next] selftests/bpf: Fix strncpy() fortify warning | expand |
diff --git a/tools/testing/selftests/bpf/cgroup_helpers.c b/tools/testing/selftests/bpf/cgroup_helpers.c index e914cc45b766..912e6522c7c5 100644 --- a/tools/testing/selftests/bpf/cgroup_helpers.c +++ b/tools/testing/selftests/bpf/cgroup_helpers.c @@ -77,7 +77,8 @@ static int __enable_controllers(const char *cgroup_path, const char *controllers enable[len] = 0; close(fd); } else { - strncpy(enable, controllers, sizeof(enable)); + enable[0] = '\0'; + strncat(enable, controllers, sizeof(enable) - 1); } snprintf(path, sizeof(path), "%s/cgroup.subtree_control", cgroup_path);