wireguard: Copy interfance names obeying lengths rules 91/261191/1
authorDaniel Wagner <wagi@monom.org>
Mon, 5 Apr 2021 15:25:27 +0000 (17:25 +0200)
committerNishant Chaprana <n.chaprana@samsung.com>
Tue, 13 Jul 2021 06:21:09 +0000 (11:51 +0530)
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 <n.chaprana@samsung.com>
vpn/plugins/wireguard.c

index ec57c93..1da0ffb 100644 (file)
@@ -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);