From d4281c2cb7c8b1ad02669a03369872230394b509 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 5 Apr 2021 17:25:27 +0200 Subject: [PATCH] wireguard: Copy interfance names obeying lengths rules MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit gcc points out the destination buffer has the same size the specified bound for the string. warning: ‘__builtin_strncpy’ specified bound 16 equals destination size [-Wstringop-truncation] Let's make sure we do not overflow the buffer (should not happen as the names are provide by the kernel and hence should fit). Change-Id: I1e8818f0820ffb32083e14cb88e4919fd8b12798 Signed-off-by: Nishant Chaprana --- vpn/plugins/wireguard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vpn/plugins/wireguard.c b/vpn/plugins/wireguard.c index ec57c93..1da0ffb 100644 --- a/vpn/plugins/wireguard.c +++ b/vpn/plugins/wireguard.c @@ -407,7 +407,7 @@ static int wg_connect(struct vpn_provider *provider, err = -ENOENT; goto done; } - stpncpy(info->device.name, ifname, sizeof(info->device.name)); + stpncpy(info->device.name, ifname, sizeof(info->device.name) - 1); g_free(ifname); err = wg_add_device(info->device.name); -- 2.7.4