mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
AF_XDP-interaction: Fix strncpy warning in common_user_bpf_xdp.c
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This commit is contained in:
@ -239,6 +239,7 @@ struct bpf_object *load_bpf_and_xdp_attach(struct config *cfg)
|
||||
struct bpf_object *bpf_obj;
|
||||
int offload_ifindex = 0;
|
||||
int prog_fd = -1;
|
||||
size_t len;
|
||||
int err;
|
||||
|
||||
/* If flags indicate hardware offload, supply ifindex */
|
||||
@ -274,8 +275,9 @@ struct bpf_object *load_bpf_and_xdp_attach(struct config *cfg)
|
||||
exit(EXIT_FAIL_BPF);
|
||||
}
|
||||
|
||||
strncpy(cfg->progsec, bpf_program__section_name(bpf_prog),
|
||||
sizeof(cfg->progsec));
|
||||
len = sizeof(cfg->progsec) - 1;
|
||||
strncpy(cfg->progsec, bpf_program__section_name(bpf_prog), len);
|
||||
cfg->progsec[len] = '\0'; /* null terminate string */
|
||||
|
||||
prog_fd = bpf_program__fd(bpf_prog);
|
||||
if (prog_fd <= 0) {
|
||||
|
Reference in New Issue
Block a user