From: Andrii Nakryiko Date: Tue, 16 Jul 2019 03:57:03 +0000 (-0700) Subject: libbpf: fix another GCC8 warning for strncpy X-Git-Tag: v5.15~5883^2~7^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=763ff0e7d9c72e7094b31e7fb84a859be9325635;p=platform%2Fkernel%2Flinux-starfive.git libbpf: fix another GCC8 warning for strncpy Similar issue was fixed in cdfc7f888c2a ("libbpf: fix GCC8 warning for strncpy") already. This one was missed. Fixing now. Cc: Magnus Karlsson Signed-off-by: Andrii Nakryiko Acked-by: Magnus Karlsson Signed-off-by: Alexei Starovoitov --- diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c index b337402..5007b5d 100644 --- a/tools/lib/bpf/xsk.c +++ b/tools/lib/bpf/xsk.c @@ -517,7 +517,8 @@ int xsk_socket__create(struct xsk_socket **xsk_ptr, const char *ifname, err = -errno; goto out_socket; } - strncpy(xsk->ifname, ifname, IFNAMSIZ); + strncpy(xsk->ifname, ifname, IFNAMSIZ - 1); + xsk->ifname[IFNAMSIZ - 1] = '\0'; err = xsk_set_xdp_socket_config(&xsk->config, usr_config); if (err)