libbpf: fix another GCC8 warning for strncpy
Subsystems (4)
PATCH 1/1 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 <[email protected]>
Signed-off-by Andrii Nakryiko <[email protected]>
--- tools/lib/bpf/xsk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/lib/bpf/xsk.c +2 -1
@@ -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)
Signature · 1 line
2.17.1
Quoted 3 lines · Andrii Nakryiko
Similar issue was fixed in
cdfc7f888c2a("libbpf: fix GCC8 warning for strncpy") already. This one was missed. Fixing now.
Thanks Andrii.
Acked-by Magnus Karlsson <[email protected]>
Quoted 23 lines
Cc Magnus Karlsson <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>--- tools/lib/bpf/xsk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tools/lib/bpf/xsk.c +2
-2@@ -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) --2.17.1
Alexei Starovoitov
AppliedQuoted 9 lines · Magnus Karlsson
Quoted 3 lines · Andrii Nakryiko
Similar issue was fixed in
cdfc7f888c2a("libbpf: fix GCC8 warning for strncpy") already. This one was missed. Fixing now.Thanks Andrii.
Acked-by Magnus Karlsson <[email protected]>
Applied. Thanks