From patchwork Thu May 10 02:47:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Green X-Patchwork-Id: 39676 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7079A1B80F; Thu, 10 May 2018 04:47:29 +0200 (CEST) Received: from mail.warmcat.com (mail.warmcat.com [163.172.24.82]) by dpdk.org (Postfix) with ESMTP id 5A8A01B815 for ; Thu, 10 May 2018 04:47:28 +0200 (CEST) From: Andy Green To: dev@dpdk.org Date: Thu, 10 May 2018 10:47:24 +0800 Message-ID: <152592044458.119328.16873411271343397611.stgit@localhost.localdomain> In-Reply-To: <152591991920.119328.14523975619615362920.stgit@localhost.localdomain> References: <152591991920.119328.14523975619615362920.stgit@localhost.localdomain> User-Agent: StGit/unknown-version Subject: [dpdk-dev] [PATCH v3 13/40] drivers/net/vdev: fix 3 x strncpy misuse X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Andy Green --- drivers/net/vdev_netvsc/vdev_netvsc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c index dca25761d..f1d036152 100644 --- a/drivers/net/vdev_netvsc/vdev_netvsc.c +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c @@ -35,6 +35,7 @@ #include #include #include +#include #define VDEV_NETVSC_DRIVER net_vdev_netvsc #define VDEV_NETVSC_DRIVER_NAME RTE_STR(VDEV_NETVSC_DRIVER) @@ -182,7 +183,7 @@ vdev_netvsc_foreach_iface(int (*func)(const struct if_nameindex *iface, is_netvsc_ret = vdev_netvsc_iface_is_netvsc(&iface[i]) ? 1 : 0; if (is_netvsc ^ is_netvsc_ret) continue; - strncpy(req.ifr_name, iface[i].if_name, sizeof(req.ifr_name)); + strlcpy(req.ifr_name, iface[i].if_name, sizeof(req.ifr_name)); if (ioctl(s, SIOCGIFHWADDR, &req) == -1) { DRV_LOG(WARNING, "cannot retrieve information about" " interface \"%s\": %s", @@ -384,7 +385,7 @@ vdev_netvsc_device_probe(const struct if_nameindex *iface, DRV_LOG(DEBUG, "NetVSC interface \"%s\" (index %u) renamed \"%s\"", ctx->if_name, ctx->if_index, iface->if_name); - strncpy(ctx->if_name, iface->if_name, sizeof(ctx->if_name)); + strlcpy(ctx->if_name, iface->if_name, sizeof(ctx->if_name)); return 0; } if (!is_same_ether_addr(eth_addr, &ctx->if_addr)) @@ -582,7 +583,7 @@ vdev_netvsc_netvsc_probe(const struct if_nameindex *iface, goto error; } ctx->id = vdev_netvsc_ctx_count; - strncpy(ctx->if_name, iface->if_name, sizeof(ctx->if_name)); + strlcpy(ctx->if_name, iface->if_name, sizeof(ctx->if_name)); ctx->if_index = iface->if_index; ctx->if_addr = *eth_addr; ctx->pipe[0] = -1;