From 6f3a354105e1b06e398d8862e05c08c8e0223383 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 30 May 2017 23:04:36 +0200 Subject: config: it's faster to memcpy than strncpy IFNAMSIZ is 16, so this is two instructions on 64-bit. --- src/config.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/config.c b/src/config.c index f3357b5..907c6b3 100644 --- a/src/config.c +++ b/src/config.c @@ -317,8 +317,7 @@ int config_get_device(struct wireguard_device *wg, void __user *user_device) out_device.version_magic = WG_API_VERSION_MAGIC; out_device.port = wg->incoming_port; out_device.fwmark = wg->fwmark; - strncpy(out_device.interface, dev->name, IFNAMSIZ - 1); - out_device.interface[IFNAMSIZ - 1] = 0; + memcpy(out_device.interface, dev->name, IFNAMSIZ); down_read(&wg->static_identity.lock); if (wg->static_identity.has_identity) { -- cgit v1.2.3-59-g8ed1b